使用c型字符指针时,使用cout输出,结果输出的是内存位置。数字的指针都没问题,求助。
char s[100];
cin>>s;
cout<<s<<endl;
是这么写的吗?
你怎么输出的,有没有加上include string
#include <string>
#include <iostream>
using namespace std;
int main()
{
char ch[] = "hello";
cout << &ch[0] << endl;
return 0;
}
http://codepad.org/QPWmU50f
在线测试没问题
我的代码是
char* h {"helo"};
cout>>h;//就这样了输出的是内存地址
cout 后面应该是<<吧