新手,求高手指点一个小bug
我想写一个存储图片的程序段,编译显示的信息是:error C2664: 'image_write' : cannot convert parameter 2 from 'struct _iobuf *' to 'char *'Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
出错的地方我用红字标出来了,等待高手指点哈
我的代码如下:
#include <stdio.h>
#include<stdlib.h>
#define X_SIZE 128 /*图像的横宽 */
#define Y_SIZE 128 /*图像的纵长 */
#define X_EXP 7 /* X_EXP=log2(X_SIZE) */
#define Y_EXP 7 /*Y_EXP=log2(X_SIZE) */
#define HIGH 255 /*2值图像的高端值 */
#define LOW 0 /*2值图像的低端值 */
int image_read(unsigned char image[Y_SIZE][X_SIZE], char *filename);
int image_write(unsigned char image[Y_SIZE][X_SIZE], char *filename);
int main ( )
{
FILE * fp=NULL; //先命名指针和定义数组
unsigned char image[Y_SIZE][X_SIZE]={{1,1,0,1},{0,0,1,0},{1,0,1}};
if((fp=fopen("c:\\test0.bmp","wb"))==NULL){
printf("write the bmp file has failed\n");
return 1;
}
image_write(image, fp);
}
int image_write(unsigned char image[128][128], char *filename)
{
FILE *fp;
fp = fopen ("test0.bmp", "wb");
if (fp == NULL) return -1;
else {
fwrite(image, (size_t)X_SIZE, (size_t)Y_SIZE, fp);
fclose(fp);
return 0;
}
}