【问题标题】:Too few arguments to function 'int fclose(FILE*)'函数'int fclose(FILE *)'的参数太少
【发布时间】:2020-11-02 13:10:36
【问题描述】:

您好,我是微处理器 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,sizeof(unsigned char),( 1600 * 1200 ) ,file);
     fclose();
    }

它给出了这个错误。函数“int fclose(FILE*)”的参数太少

【问题讨论】:

  • 你想关闭一个文件,如果你不提供文件作为参数,函数如何知道要关闭哪个文件?
  • 您的问题到底是什么?错误信息似乎很清楚。
  • @UğurÇınar 你得到的答案没有回答问题吗?如果有,请accept它。

标签: c++ microprocessors


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-18
    • 2021-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-16
    • 2017-04-01
    相关资源
    最近更新 更多