Created
May 2, 2012 03:56
-
-
Save cammckinnon/2573492 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <stdio.h> | |
/* | |
compiles with 'gcc -Wall' with no errors or warnings. | |
*/ | |
int main() { | |
// vars | |
int a[10]; | |
int i = 0; | |
long long L = 0; | |
//populate array | |
for (; i < 10; i ++) { | |
a[i] = i; | |
} | |
// sizes | |
printf("sizeof(int) = %d\n", sizeof(int)); | |
printf("sizeof(long long) = %d\n", sizeof(long long)); | |
printf("sizeof(int*) = %d\n", sizeof(int*)); | |
printf("\n"); | |
//indexing | |
printf("a[5] = %d\n", a[5]); | |
printf("5[a] = %d\n", 5[a]); | |
printf("a[5LL] = %d\n", a[5LL]); | |
printf("5LL[a] = %d\n", 5LL[a]); | |
printf("\n"); | |
printf("i = %d \nL = %d\n", i = 5, (int)(L = 5)); | |
printf("a[i] = %d\n", a[i]); | |
printf("i[a] = %d\n", i[a]); | |
printf("a[L] = %d\n", a[L]); | |
printf("L[a] = %d\n", L[a]); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment