468,512 Members | 1,431 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

Reading a comma separated file

I have a very simple question, but I am rather inexperienced in C so I can't figure it out.

I have a bunch of comma separated files, and each field is in quotation marks. Individual records are separated by carriage returns. I want to be able to to go a given record (a specific line in the file) and the read the data in a specific field in that record into an int or a char depending on whether the entry in that field is a number or text.

So, how can I do this?
Aug 5 '06 #1
1 5649
9,056 Expert Mod 8TB
Open the file
Read the line you require into a string (this in itself is not entirely simple)
Use a pointer to scan along the line to the field you require
Check to see if the field is a number or a string
If it's a number convert the text to the binary number
If it's a string just copy it to your output buffer
Close the file again

Look up functions



char array (string) handling.
Aug 5 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by John B. Lorenz | last post: by
2 posts views Thread by pesso | last post: by
29 posts views Thread by yourmycaffiene | last post: by
2 posts views Thread by rodchar | last post: by
2 posts views Thread by Wes Peters | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.