函数'int fcloseFILE *'的参数太少

问题描述

您好,我是微处理器C语言的初学者。我想读取一个“ .bmp”文件,以便对其应用行检测。我已经声明了读取图像的功能。按下编译按钮时会发生此错误:

#include "esp_camera.h"
#include "Arduino.h"
#include "FS.h"                // SD Card ESP32
#include "SD_MMC.h"            // SD Card ESP32
#include "soc/soc.h"           // Disable brownour problems
#include "soc/rtc_cntl_reg.h"  // Disable brownour problems
#include "driver/rtc_io.h"
#include <EEPROM.h>            // read and write from flash memory
#include <SPI.h>

  void imageReader(const char *imgName,int *height,int *width,int *bitdepth,unsigned char *header,unsigned char *_colortable,unsigned char *buf
    ) // READ AN IMAGE
  {
     int i;
     fs::FS &fs = SD_MMC;  // 
     FILE *file;
     file = fopen(imgName,"rb"); // read imgName file ( it is a picture in .bmp format )
     if(!file){
        Serial.printf("Unable to read image");
     }
     for(i=0 ; i<54 ; i++){
        header[i]=getc(file);
     }
     *width = *(int * )& header[18]; // width information of the image
     *height = *(int * )& header[22]; // height information of image
     *bitdepth = *(int *)& header[28];
     if(*bitdepth<=8){
        fread(_colortable,sizeof(unsigned char),1024,file);
     }
     fread(buf,( 1600 * 1200 ),file);
     fclose();
    }

出现此错误。函数'int fclose(FILE *)'的参数太少

解决方法

fclose()函数需要知道要关闭哪个文件。您需要通过提供“文件”作为参数来告诉它。您要使用fclose(file)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...