/** 不可以對數組名進行++操作,因為數組名是一個常量,其值是不能被改變的 **/ #include <stdio.h> int main() { ///字符數組 char a[10]; gets(a); while((*a) != '\0'){ printf("%c",(*a)); a++; } ///整形數組 int b[10]; int i; for(i=0;i<4;i++){ b[i]=i+1; } b++; printf("%d\n",(*b)); }
標紅的兩行會報錯,如果用code::blocks編譯的話,它會提示:error: lvalue required as increment operand,意思就是不能改變數組名的值