c++的大问题,新手不知道该怎么下手
为什么输出会是这样。。。那些“烫烫”哪里来的。。。。疯了。。#include<iostream>#include<cstring>usingnamespacestd;ch...
为什么输出会是这样。。。那些“烫烫”哪里来的。。。。疯了。。
#include<iostream>
#include<cstring>
using namespace std;
char *ps(void);
int main(){
char *name;
name = ps();
cout << name << " at " << *name << endl;
system("pause");
return 0;
}
char * ps(){
char temp[80];
cout << "Please enter your name: ";
cin >> temp;
char *p = new char[strlen(temp) + 1];
p = temp;
return p;
} 展开
#include<iostream>
#include<cstring>
using namespace std;
char *ps(void);
int main(){
char *name;
name = ps();
cout << name << " at " << *name << endl;
system("pause");
return 0;
}
char * ps(){
char temp[80];
cout << "Please enter your name: ";
cin >> temp;
char *p = new char[strlen(temp) + 1];
p = temp;
return p;
} 展开
1个回答
2015-01-08
展开全部
#include<iostream>
#include<cstring>
using namespace std;
char *ps(void);
int main(){
char *name;
name = ps();
cout << name << " at " << &name << endl;
system("pause");
return 0;
}
char * ps(){
char temp[80];
cout << "Please enter your name: ";
cin >> temp;
char *p = new char[strlen(temp) + 1];
strcpy(p, temp);
return p;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询