help needed ( urgent )
Posted on 1997-05-01
I have the following code that reads in a .txt file and stores it into an array.
A typical .txt file format that I would want to read in is :
Now the little program I have reads the file and stores each line as characters ( I THINK ! ). This is no good since I can not perform any mathematical operation on the contents of the array.
Does anyone know how to modify the program so that it reads in the file and stores the contens as numbers in the array.
The code is
#define MAX_LINE 20
void main( void )
int nCount = 0;
const int ArSize = 12 ;
char file[ArSize] ;
cout<< "Enter file name to load please : " ;
cin >> file ;
if( (stream = fopen( file, "r" )) != NULL )
while ( fgets( line, MAX_LINE, stream ) != NULL)
array[nCount] = new char[strlen(line)+1];
fclose( stream );
printf("readed lines %d\n", nCount);
// Don't for get to delete all the Array elements before leaving!
cout << array << "\n"