ビットマップ画像を開いて寸法を画像に保存するプログラムをCで作成しました。fread関数を書くのに問題があります。私が書いたコードの関数の正しい形式を教えてください。コードに何か問題がありますか?
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
void fskip(FILE *fp, int num_bytes)
{
int i;
for (i=0; i<num_bytes; i++)
fgetc(fp);
}
typedef struct tagBITMAP /* The structure for a bitmap. */
{
int width;
int height;
//unsigned char *data;
} BITMAP;
int main()
{
int temp1=0;
BITMAP *bmp[50];
FILE *fp = fopen("splash.bmp","rb");
if (fp!=NULL && (fgetc(fp[count])=='B' && fgetc(fp[count])=='M')){
bmp[temp1] = (BITMAP *) malloc (sizeof(BITMAP));
fskip(fp,16);
fread(&bmp[temp1].width, sizeof(int), 1, fp);
fskip(fp,2);
fread(&bmp[temp1].height,sizeof(int), 1, fp);
fclose(fp);
}
else exit(0);
getch();
}