I have problem when I load text file line by line. Most of the time the code below works but whensay somewhere in the middle of a string that I am loading is hidden a carriage return then the CStdioFile::ReadString will read the string only up to the carriage return and the rest of the string after the carriage return is ignored. Is it because I amloading the file as text?
#include <windows.h>
void LoadFile( const CString &path, UINT nOpenFlags )
{
CStdioFile file;
CString row;
if( file.Open( path, nOpenFlags ) )
{
int countLines = 0;
//reads line by line untill the end of file
//here is the problem half line is read & stored in "row" up to hidden carriage return
while ( file.ReadString( row ) != NULL )
{
++countLines;
}
file.Close();
}
}
void main()
{
LoadFile( "c:\\windows\\data.txt", CFile::modeRead | CFile::shareDenyWrite);
}
Any suggestions how to resolve this so I can read entire line of text ignoring carriage return. But actually I am not reading the line but the CStdioFile::ReadString function does which means that I am a bit limited. Am I? Any suggestions how to resolve it using CStdioFile functions or any other loading tools with bigger flexibility? Samples of code would be a big help. I am loading mainly CSV files with thousands of lines of text separated with commas so I need something very effecient.