Read line in from text file using C/C++ - TechRepublic
General discussion
April 26, 2002 at 04:32 AM
cp409sd

Read line in from text file using C/C++

by cp409sd . Updated 24 years, 1 month ago

I am new to C++ programming, so this might seem pretty trivial. I am trying to find the most simple way to read a line in from a text file and store it. I am able to open the file, but I am having trouble reading it in correctly. I would like to read the entire line in, and stop reading at the end of the line. I figure I want to put the line into a character array that will hold it. I don’t think I want to store white space between characters. After reading the line in, I would do my processing, then continue reading lines in until EOF.

Thanks for any help you can provide me in doing this. By the way, if it is easier to do this using C as opposed to C++ commands, it does not matter.

This discussion is locked

All Comments