bool CTextFormat::ToFloat(const char* fpath, char delim)
{
fstream file(fpath, ios::in);
stringstream sBuf;
string str;
float f1[20][3] = {0};
float f2[20][3] = {0};
int count = 0;
if( !file )
{
// TODO:
return false;
}
while( getline(file, str) )
{
if( *(str.c_str()) == NULL ) break;
sBuf.str(str);
for(int i=0; i<3; )
{
if( sBuf >> f1[count][i] )
i++;
else
return false;
}
count++;
str.clear();
sBuf.clear();
}
for( int i=0; i<20; i++)
cout << f1[i][0] << f1[i][1] << f1[i][2] << endl;
count = 0;
while( getline(file, str) )
{
if( *(str.c_str()) == NULL ) break;
sBuf.str(str);
for(int i=0; i<3; )
{
if( sBuf >> f2[count][i] )
i++;
else
return false;
}
count++;
str.clear();
sBuf.clear();
}
for( int i=0; i<20; i++)
cout << f2[i][0] << f2[i][1] << f2[i][2] << endl;
file.close();
}