Hello, I am coping a problem with getline.
I have a txt file that looks like the following.And my task is to read it and put them in a file that contains 10 columns and not 8.
0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,1
0,0,0,0,0,0,1,0
0,0,0,0,1,0,0,0
0,0,0,1,0,0,0,1
0,2,2,1,0,2,6,5
12,17,12,28,39,40,46,71
and I have to read them and put them in an other file
so my code so far is:
int array[32768];
int i=0, j;
char cNum[1000] ;
char dum [256];
if (dum[0]=='0')
{
do {
myfile.getline(cNum, 256,',');
array[i]= (int)atoi(cNum) ;
cout << cNum;
i++ ;
}
while (! myfile.eof() );
}
else
{
continue;
}
for (j=0;j<i;j++)
{
cout << array[j]<<" ";
cout << cNum << " ";
if (!(j%10))
cout <<endl;
}
And the output file it that one:
0
0 0 0 0 0 0 1 0 0 0
0 0 1 0 0 0 0 1 0 0
0 0 0 1 0 0 0 1 2 2
1 0 2 6 5 17 12 28 39 40
Can you pls tell me what I am missing here ?? :-(