解释下,越细越好
#include "stdafx.h"
#include <iostream>
using namespace std;
const char *st = "The expense of spirit\n";
int main()
{
int len = 0;
while ( st++ )
{
++len;
}
cout << len << "; " << st;
return 0;
}
const char *st = "The expense of spirit\n";
const char *p = st;
int main()
{
int len = 0;
while ( p++ )
{
++len;
}
cout << len << "; " << st;
return 0;
}
第一个是错误,第二个可以,不懂为什么