A simple C-voice problem.
The code is as follows:
#include
typedef unsigned char Us_char;
int main ()
{
Defining two-dimensional arrays for storing picture information
Us_char img[256][256];
FILE *FP = fopen ("31015_h1.raw", "WB");
if (!FP)
{
printf ("Erro");
return 1;
}
for (int i = 0; i<256; i++)
for (int j = 0; j<256; j + +)
IMG[I][J] = (Us_char) J;
Fwrite (IMG, sizeof (IMG), n, FP);//write
Fclose (FP);
return 0;
}
The output image is as follows:
If the file *FP = fopen ("31015_h1.raw", "WB"), the "WB" is changed to "B"
The output image is as follows:
This I can not think of the solution ah, the prawn could help me explain, thank you!
------to solve the idea----------------------
"WB" changed to "B" is less write.
It is estimated that 31015_h1.raw is a figure two.
------to solve the idea----------------------
FILE *FP = fopen ("31015_h1.raw", "B");
Isn't that a mistake?
Is that right?
FILE *FP = fopen ("31015_h1.raw", "w");
Your J cycle is from 0 to 255.
When j = 10 o'clock, (Us_char) j is the newline character, the window Chinese text line break will automatically add a carriage return character
So the whole thing was misplaced.