Archived

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

Using stdio.h, fgets to read a file, how to make it auto read length of each line?

This topic is 5178 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

When I used visual basic method of loading text files, it automatically loaded the entire line. Thats what i want to do now. using the: stdio.h, fgets fgets requires me to enter the max length to read on the line. So i want to work out how long the current line is, so my read wrapper method doesnt require the input of how much of the line iwant read. Thanks

Share this post


Link to post
Share on other sites
The ''max length'' parameter should just be the size of the buffer that you''re reading into. This is so that the fgets function doesn''t write past the end of the buffer and cause your program to crash. If you want to just read the line, no matter how long it is, then look at std::string and std::fstream.

Share this post


Link to post
Share on other sites