作者lalas (Prison Break好看!)
看板C_and_CPP
標題[問題] 指標 與 字串 問題
時間Sat Oct 17 22:25:47 2009
簡單程式碼如下
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
char *ptr="AGTWE";
*ptr++; \\這裡為什麼不是 *ptr=*ptr+1 而是有ptr=ptr+1的感覺呢?
printf("%c\n",*ptr);
system("pause");
return 0;
}
為什麼輸出的結果不是 B 而是 G?
小弟不才 請多指教~~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.240.102.22
1F:推 cplusplus:運算子順序 * 比 ++ 低囉 10/17 22:27