c++指针(while条件中的cp,运行为什么会出错?而*cp正确?二者区别?虚心求教!谢谢!)
while条件中的cp,运行为什么会出错?而*cp正确?二者区别?虚心求教!谢谢!
#include <iostream> using namespace std; void main() { const char *cp="hello!"; int cnt=0; while(cp) { ++cnt;++cp; cout<<cnt<<endl; cout<<*cp<<endl; cout<<(*cp)<<endl; }
}