-
-
Save kasramp/cf17cbf49687da1dc2e0c97f5402d20e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(int argc, char *argv[]) { | |
int x[3] = {1, 2, 3}; | |
int *p; | |
p=x; | |
cout << *p; //prints x[0]; | |
cout << ++*p; //prints x[1]; | |
cout << p[1]; //prints x[1]; | |
cout << *x; //prints x[0]; | |
cout << ++*x; //prints x[1]; | |
cout << *++x; //Compile error; | |
cout << *x++; //Compile error; | |
p = &x; //Compile error; | |
p = &x[0]; //p points to first element of x; | |
cout << *p; //prints x[0]; | |
cout << ++*p; //prints x[1]; | |
cout << p[1]; //prints x[1]; | |
cout << *++p; //prints x[1]; | |
cout << *(++p); //prints x[1]; | |
cout << *(p++); //prints x[0]; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment