Is that about stack? I think the last *p++
is undefined. *p++
means *(p++)
or *p;p++;
?
void test123()
{
char s[] = "123", * p;
p = s;
// 1 2 3
cout << *p++ << endl;
cout << *p++ << endl;
cout << *p++ << endl;
}
void test321()
{
char s[] = "123", * p;
p = s;
//321
cout << *p++ << *p++ << *p++ << endl;
}
int main(void)
{
cout << "123:" << endl;
test123();
cout << "123:" << endl;
test321();
cout << "hello world" << endl;
return 0;
}
I think the result is undefined.