Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading the First Line of a File into CString

Status
Not open for further replies.

thebarslider

Programmer
Dec 21, 2001
80
0
0
GB
I wish to read the first line of file into a CString.

I can open the file but cannot read the first line delimitated by \n.

I've spent ages trying to work this out but to no avail.

I have opened the file using CFile but cannot get any further.

Any help would be much appreciated.
 
Er whoops i meant you're gonna have to change the cin part to the infile stream ;xxx
 
hey there,

i've attempted to use this function before but how could read the file in properly.

Do you know how i open the file so that i can place a handle/pointer to it in this stream

I am using MFC so CFile extra is open to be but i cant find and methods in CFile to read in one line.

Mark
 
You can use the ReadString method of CStdioFile, which is a subclass of CFile and in other aspects nehaves just like a CFile, construction, Open, etc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top