• We should now be fully online following an overnight outage. Apologies for any inconvenience, we do not expect there to be any further issues.

Question involving files. C/C++

DarkForceRising

Senior member
Apr 16, 2005
407
0
71
What are the C commands involving files? Specifically, are there any commands allowing someone to move through text files line by line? Word by word? I have to parse a string that looks like "[permissions] [owner] [size] [date accessed] [filename]." There will be a list of these in another file. I need to be able to add, remove, and modify entries. And I have no idea how to do this. Any thoughts?
 

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
Are you using C or C++? They're different languages, and the answer is VERY different. Also, neither of them is really a good choice of language based on the information you've provided. Do you have the option to use something else (e.g. perl)?
 

DarkForceRising

Senior member
Apr 16, 2005
407
0
71
I program in C, but I'm using Visual C++ to compile, etc. So it supports both. So C would be preferable. No, I don't really have any other choices, as this is a school project, and C is the only language I know.

But like I said, I need to maintain a list of entries in a file that I can read to get information. I'm going to see my professor in the morning, and it's possible that he will suggest a completely different format, but that is what I thought he wanted us to do.
 

DarkForceRising

Senior member
Apr 16, 2005
407
0
71
Hallelujah, I'm almost finished. That link had an example that helped me out a ton. I ended up formatting it completely differently than I was going to, but it worked out much better in the end. Thanks a bundle.
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Getline will work best to get a line at a time.

After than you need to use a token parser with spaces as the delimiter to strip out words.