I am using this code to try to read an entire file into an array
But when I tested it, by printing the contents of M[] to the screen, I just get zeroes for all elements.Code:#include <fstream> typedef unsigned long int ULI; . . . ULI M[numElements]; //creates an unsigned long int array, numElements is sufficient to hold the entire file for(i=0;i<numElements;i++) { M[i]=0; } //open the file ifstream fin(filename,ios::binary); //read it into M[] fin.read((ULI *) &M, flen); fin.close();
What's wrong with the code? It all compiles without any errors. This is in DOS by the way, DJGPP compiler.




Reply With Quote