I am Creating a MFC Application to Read a Text file into a Edit Box. I am implementing the following code
FILE *m_pFile ;
CString m_strLine , m_strText;
char line [1000] = "" ;
m_pFile = fopen ( "C:\\SELF.txt" , "r" ) ;
if ( m_pFile != NULL )
{
// read each line in the file
while(fgets(line,sizeof(line),m_pFile) != NULL)
{
// convert the line to a CString
m_strLine = line ;
// format the string for the edit control
m_strLine.Replace ( '\n' , '\r\n' ); //PROBLEM HERE
// store each line to the text string
m_strText += m_strLine ;
}
}
// write all the text to the edit box at once
GetDlgItem(IDC_EDIT1)->SetWindowTextW( m_strText ) ;
// close the file
fclose ( m_pFile );
All The text is appearing without the line feed. Please Help!!! :'(
I am Using Visual Studio 2008.
Alternate Suggestions are Welcome.