field delimiters / scanning in file I/O
Can someone please explain to me how to use field delimiters (like commas and newlines) during file input / output?
I need to be able to read characters from a file into a char array until a delimiter is reached (like when reading a filename). Also, I want to read in these delimited values until a newline is reached. I think I can handle the EOF.
I want to use fopen, fclose, fscan, fread etc.. - how do you read all of the characters before the next delimiter into a buffer, and also check if the end of a line is reached (and I guess how to start reading at the next line when this occurs)?
Also, how do you write a delimiter between fields?
Thanks,
Paulcoz.
Edited by - paulcoz on March 20, 2001 9:05:04 PM
Well, the easiest way is to just have a buffer (char array) that you fill until you read that symbol, then stop filling the buffer, and hop over the symbol
. You can use strtok if you have the data in a buffer already...
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
![Resist Windows XP''s Invasive Production Activation Technology!](http://www.crosswinds.net/~druidgames/resist.jpg)
http://www.gdarchive.net/druidgames/
![](wink.gif)
|
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
![Resist Windows XP''s Invasive Production Activation Technology!](http://www.crosswinds.net/~druidgames/resist.jpg)
http://www.gdarchive.net/druidgames/
The source tags don''t like to word wrap I guess
.
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
![Resist Windows XP''s Invasive Production Activation Technology!](http://www.crosswinds.net/~druidgames/resist.jpg)
http://www.gdarchive.net/druidgames/
![](smile.gif)
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
![Resist Windows XP''s Invasive Production Activation Technology!](http://www.crosswinds.net/~druidgames/resist.jpg)
http://www.gdarchive.net/druidgames/
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement