读书人

[hello world]菜鸟问个char *的有关问

发布时间: 2012-09-09 09:27:54 作者: rapoo

[hello world]初学者问个char *的问题

C/C++ code
  int index = 0;       string s1 = "hello world" ;       string *_ = &s1;       char *s1p = &(s1[index]);      cout << _ << endl;      cout << s1p <<endl;      cout << *( s1p+1) << endl;//输出     0x22ff40     hello world     e

dev c++ 5上编的
第二个为甚么是hello world呢


[解决办法]
就是这么定义的

cout一个char*,就输出该地址其实的c风格字符串
[解决办法]
要输出地址,就cout << (void*)s1p <<endl;

读书人网 >C++

热点推荐