Connecting Tech Pros Worldwide Forums | Help | Site Map

line by line read

Newbie
 
Join Date: Oct 2007
Posts: 4
#1: Oct 26 '07
i want to know how to read the strings from a text file line by line in C++ and/or in C. can u plz help me ?

sicarie's Avatar
Moderator
 
Join Date: Nov 2006
Location: USA
Posts: 3,929
#2: Oct 26 '07

re: line by line read


Quote:

Originally Posted by maheshmadhavan

i want to know how to read the strings from a text file line by line in C++ and/or in C. can u plz help me ?

Sure what have you tried? What have you found in your research? Did you try googling 'c (or c++) file io'?
Moderator
 
Join Date: Mar 2007
Location: North Bend Washington USA
Posts: 5,370
#3: Oct 27 '07

re: line by line read


Look up the getline functions.
Member
 
Join Date: Aug 2007
Location: Sydney
Posts: 123
#4: Oct 28 '07

re: line by line read


Quote:

Originally Posted by maheshmadhavan

i want to know how to read the strings from a text file line by line in C++ and/or in C. can u plz help me ?

fgets is the method that would "read a file line by line".

Google for tutorials regarding this method plz.
Moderator
 
Join Date: Mar 2007
Location: North Bend Washington USA
Posts: 5,370
#5: Oct 28 '07

re: line by line read


Quote:

Originally Posted by mattmao

fgets is the method that would "read a file line by line".

That's C.

C++ uses other methods like getline or the >> operator.
sicarie's Avatar
Moderator
 
Join Date: Nov 2006
Location: USA
Posts: 3,929
#6: Nov 3 '07

re: line by line read


maheshmadhavan-

I have deleted your other post asking this same question. You have 3 responses, either reply to them with what you tried and why it is or is not working, or a more specific question.
Reply