Created
April 20, 2015 19:22
-
-
Save teamdandelion/a6559bf5fcaae4b2ba32 to your computer and use it in GitHub Desktop.
c-onfusion
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
#define BUFFER_SIZE 4 | |
struct message { | |
int content; | |
}; | |
struct message buffer[BUFFER_SIZE]; | |
int main() { | |
int i; | |
printf("allocated buffer, have done nothing with it"); | |
printBuffer(); | |
for (i=0; i<BUFFER_SIZE; i++) { | |
struct message m = buffer[i]; | |
m.content = 99; | |
} | |
printf("assignment sequence 1"); | |
printBuffer(); | |
for (i=0; i<BUFFER_SIZE; i++) { | |
buffer[i].content = 99; | |
} | |
printf("assignment sequence 2"); | |
printBuffer(); | |
} | |
output from running this program: | |
>>>allocated buffer, have done nothing with it[0,0,0,0,] | |
>>>assignment sequence 1[0,0,0,0,] | |
>>>assignment sequence 2[99,99,99,99,] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment