一个类型转换的有关问题
求教:一个类型转换的问题
有这样一个函数
从文件中获取指定的字符串的值,其中前三个变量是输入,第四个变量retvalue是输出
按照如下方式调用这个函数
提示函数不能将参数4从“char **__w64 ”转换为“const char **”
请问这个问题该怎么解决,谢谢
------解决方案--------------------
用const char *handlerType;呢?
------解决方案--------------------
char* s;
const char* p = (const char*)(char*)s;
参考一下这个
------解决方案--------------------
亲测可用
有这样一个函数
- C/C++ code
extern "C" bool GetStringProperty( FILE *fp,int index; const char* propName, const char **retvalue)
从文件中获取指定的字符串的值,其中前三个变量是输入,第四个变量retvalue是输出
按照如下方式调用这个函数
- C/C++ code
char *handlerType; handlerType=(char *)malloc(10*sizeof(char)); GetStringProperty( FILE *fp, int index; const char* propName, &handlerType);
提示函数不能将参数4从“char **__w64 ”转换为“const char **”
请问这个问题该怎么解决,谢谢
------解决方案--------------------
用const char *handlerType;呢?
------解决方案--------------------
char* s;
const char* p = (const char*)(char*)s;
参考一下这个
------解决方案--------------------
亲测可用
- C/C++ code
#include<stdlib.h> #include<stdio.h> extern "C" bool GetStringProperty( FILE *fp, int index, const char* propName, const char **retvalue ){ return 0; } int main(void){ FILE *a = 0; int b = 0; const char *c = 0; const char *handlerType =(char *)malloc(10*sizeof(char)); GetStringProperty( a, b, c, &handlerType ); return 0; }
------解决方案--------------------
问题还是出在你是先声明后赋值上...你的handlerType前面没有类型名,或者你把malloc前面那个char*去掉