I was reading the following question:
How to read MNIST data in C++?
and there was some C++ code for reading the MNIST database. Upon trying it I found out that it worked fine until the place where it started reading the data.
which is the following code:
unsigned char temp=0;
//cout<<(int)temp<<" "; //printing the pixel in integer format
When working with the MNIST data set, I had the same problem that you had. I could read the labels, but the training and test set images were mostly bogus; the training set was filled almost entirely with 175, and the testing set was filled almost entirely with 0s (except for the first 6 images). Rebooting did not fix the problem and I was unable to determine why the file reading was not working correctly.
For anyone with this same problem, I would suggest instead using the data files located at http://cis.jhu.edu/~sachin/digit/digit.html. The data is already organized by number (no label/image association required), and the arrays of pixel values are simply encoded one after the other. Knowing that each array is 28x28 and that there are 1000 images for each number, you can easily write code to input the individual image arrays of pixel values.