Archived

This topic is now archived and is closed to further replies.

File stream and 'end of line' character

This topic is 5277 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there a way to read a line of input from a file and also keep the end of line character? inFile >> buffer and inFile.getline eats it. --------------------- My specs (because I always forget to post them) Intel P4 2.4 GHz 640 MB system memory Radeon 9700 PRO Windows XP DirectX 9 DirectX 8.1 SDK

Share this post


Link to post
Share on other sites
Well, I''m reading into the same character array over and over again. I needed a way to keep the end of line character for a delimiter in my program. I used a work around that works fine, but is a bit sloppy. I just traverse through the array resetting all subscripts to a certain character. The program is for my compilers class and converts regular expressions to a DFA table, then runs strings through the table to tell if they are valid or not.

Share this post


Link to post
Share on other sites
How about just using get()? I don''t think that extracts the newline characters, but does stop when it finds one. Have to keep calling until it hits EOF.

Int.

Share this post


Link to post
Share on other sites
I really don''t see the problem using getline. It always puts a 0 terminator at the end of the line it gets. Can''t that 0 be the delimiter you need?

Share this post


Link to post
Share on other sites