指针是一把双刃剑!
程序代码:#include<iostream>
using namespace std;
char *getname(void);
int main ()
{
char *name;
name = getname();
cout << name << " at " << (int *)name << endl;
delete [] name;
name = getname();
cout << name << " at " << (int *)name << endl;
delete [] name;
return 0;
}
string *getmane()
{
char temp(80);
cout << "enter last name : ";
cin >> temp;
char * ps =new char[strlen(temp)+1];//错误语句
strcpy(ps,temp);
return ps;
}提示的错误为:F:\test\test.cpp(245) : error C2664: 'strlen' : cannot convert parameter 1 from 'char' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
想请教大家 为什么会出错?





抄都抄错
确实,错误是pass它妈!楼主应该英语不怎么好!