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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding a carriage return to data when writing to a file

Status
Not open for further replies.

Pyropat

Programmer
May 21, 2001
9
0
0
US
I have some data I am sending to a file using the CFile class. I want it to start a new line after every piece of data. How do I do this?
some of my code:
CFile LoginFileWrite;
LoginFileWrite.Open("login.txt",CFile::modeWrite);
CString NewName;
CString NewPass;
CString NewData;
NewName = m_NewName;
NewPass = m_NewPass;
NewData.Format(NewName + " " + NewPass);
int NewDataLen;
NewDataLen = NewData.GetLength();
LoginFileWrite.SeekToEnd();
LoginFileWrite.Write(NewData, NewDataLen);
LoginFileWrite.Close();
 
Just append to your data a "\n".

NewData.Format(NewName + " " + NewPass + "\n");

That should do the trick.

HTH
William
Software Engineer
ICQ No. 56047340
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top