#include
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;
}
}
#include
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;
}
}
while(cp)
cp的值不为0就会一直循环
while(*cp)
*cp的值为字符串末尾时为'\0',ASII码值为0,就会停止循环。