我用 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)=='B' && fgetc(fp)=='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();
     }