I have txt-file and I have to check if it is in right format. something like:
-;666;2006-12-12;-;help me! (there could be more lines than one)
So, how do I check the right number of ';' and that they are in right places...??? And how I get that kind of timestamp?
handling txt-files!
Started by carita88, Dec 12 2006 03:50 AM
6 replies to this topic
#1
Posted 12 December 2006 - 03:50 AM
|
|
|
#2
Posted 12 December 2006 - 06:30 AM
This is what you will need to do:
Open the text File
Split the text file by line breaks (\r\n or \n or \r)
Loop through each line
Split each line by ;
print the value
End Loop
Are you using Ansi C++? If so, I'll post some code.
Open the text File
Split the text file by line breaks (\r\n or \n or \r)
Loop through each line
Split each line by ;
print the value
End Loop
Are you using Ansi C++? If so, I'll post some code.
#3
Posted 12 December 2006 - 06:21 PM
A lot of the answer will depend on whether you are using C or C++. C++ allows you to make use of the string class and all its power, whereas with C you'll have to code everything by hand. In C, the key will be knowing that strings are really just arrays, and you can use for loops to traverse them looking for the semi-colons.
#4
Posted 12 December 2006 - 11:14 PM
using c. I will have to print whole lines and be able to handle those "values" between each ';'. Do I have to save each value to it's own array or is it better to use tables?
#5
Posted 13 December 2006 - 08:14 AM
I don't much about splitting in C but I assume you could add the value of the string to another string util you reach a ;. Once a ; is reached you could simply print that value and start over.
Void
#6
Posted 13 December 2006 - 09:41 AM
Look at the string functions in C.
#7
Posted 13 December 2006 - 09:49 AM
Well I dont know any C or so.. but this may help perhaps?
Attached source:-
Attached source:-


Sign In
Create Account

Back to top










