本文中需要使用fopen()函数读取文件,然而我的路径是Cstring类型,因此,需要转换一下类型
完整代码如下:
FILE *f_raw_in = NULL;
//Cstring 转 const char *
CString imagePath = "c:\test\test.jpg";
string strpath = CT2A(imagePath);
const char * filepath = strpath.c_str();
if ((f_raw_in = fopen(filepath , "r")) == NULL)
{
printf("can not open the image.\n ");
fclose(f_raw_in);
return -1;
}
else
{
printf("read raw OK\n");
}