C++报错什么意思

来源:百度知道 编辑:UC知道 时间:2024/06/08 00:48:34
H:\chengji\chengji.cpp(48) : error C2664: 'strcpy' : cannot convert parameter 2 from 'char' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
代码用百度发了
帮忙改下谢谢

是strcpy的参数出错了
标准的参数表如右:char *strcpy(char *dest,char *src);
我想你可能是把常指针或是常字符串当做参数传递进去了。

如果还没找出错误的话,你可以把完整代码贴上来

字符串复制的时候
不能把第二个char类型的参数赋值给类型为const cha*的参数
定义参数类型出错

H:\chengji\chengji.cpp(48) : error C2664: 'strcpy' : cannot convert parameter 2 from 'char' to 'const char *'
这一句的意思是:strcpy函数不能把第二个char类型的参数转换为const char *
指针参数类型。可以肯定的是你传递参数是把一个char类型的实参传给了指针形参。应该是你在输入的时候忘记输入:&取地址符了。

Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
这一句是告诉你如果要把数值转换为指针那么要用到这些关键字reinterpret_cast, C-style cast or function-style cast,你在百度里输入
reinterpret_cast,点击第一个链接可以教你怎么使用。

函数原型:char *strcpy(char *dest,char *src);
char a[10];
char b[10] = "abcdefg";
strcpy(a,b);
strcpy(a,"abcdefg");
这两种写法才是对的