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!

CFile problem

Status
Not open for further replies.

raochetan

Programmer
Aug 20, 2001
62
IN
I am creating a text file using CFile Object. The code is as below:

CFile filePtr.
CFileException e;
CString fileName = "textfile.txt";
CString data;

if( filePtr.Open( fileName.operator LPCTSTR(), CFile::modeCreate | CFile::modeWrite, &e) )
{
// do something if error occurs
}

data = "This is the first Line of Test.\n";
filePtr.Write( data.operator LPCTSTR(), data.GetLength() );
data = "This is the Second Line of Test.\n";
filePtr.Write( data.operator LPCTSTR(), data.GetLength() );
data = "This is the Third Line of Test.\n";
filePtr.Write( data.operator LPCTSTR(), data.GetLength() );

filePtr.Close();


When i open the file created using notepad, the 3 sentences are in the same line. The new line character '\n' is displayed as some black rectangle character.

If i open the same file in Word Pad, it is displayed in 3 different lines as expected.

I cannot understand what is problem. Is there any solution to this?

In my system, the users will use a notepad to open the file.

Please help.

Thanks in advance.

raochetan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top