Reading a ppm file

Hey, I have a ppm file and I want to try and use it for texture mapping. I am trying to write a function to read in all the RGB values and store them in an array. Then I plan to use glTexImage2D().

Given the ascii header:

P6
1024 1024
255

is this code correct? I am getting a blank screen at the moment. If I add a line, say aByte = 255; in the inner most for loop my rendering appears completely white as you might expect. Funnily enough If I add ‘cout << aByte’ instead I do get lots of values between 0 and about 30, but still get a blank screen?


  FILE * file;
  char aByte;

 file = fopen ( "theImage.ppm" , "rb" );

   for (int i = 0;i<1024;i++){
	   for(int j = 0; j <1024;j++){
		 for (int c = 0; c < 3; c++){
				  aByte =  fgetc(file);
				  image[i][j][c] = aByte;
			  }
	   }
   }

Thanks for any help.

Sorry, I found the problem elsewhere