Forum Discussion
Altera_Forum
Honored Contributor
20 years agoI'm assuming K is the size of the file you want to read so you could try:
fread(p, 1, K, fp); which reads K "items" of size 1 byte. fread returns the number of items read so you can test whether it worked like this: numRead =fread(p,1,K,fp); if (numRead != K) printf("read only %d of %d\n", numRead, K); The reason you cannot use fgets is that that function stops when it encounters a newline in the data. By the way, you can look at the Windows structures BITMAPFILEHEADER and BITMAPINFO to find a way of properly parsing out a bitmap. Andrew