Adding comments and modifying code to include changes made since last reading

This commit is contained in:
Dan Buch 2012-02-13 22:08:28 -05:00
parent 2345f4fa0b
commit 2e571b4641

14
ex9.c
View File

@ -5,6 +5,7 @@ int main(int argc, char *argv[])
int numbers[4] = {0};
char name[4] = {'a'};
// first, print them out raw
printf("numbers: %d %d %d %d\n",
numbers[0], numbers[1],
numbers[2], numbers[3]);
@ -15,11 +16,13 @@ int main(int argc, char *argv[])
printf("name: %s\n", name);
// setup the numbers
numbers[0] = 1;
numbers[1] = 2;
numbers[2] = 3;
numbers[3] = 4;
// setup the name
name[0] = 'Z';
name[1] = 'e';
name[2] = 'd';
@ -32,6 +35,7 @@ int main(int argc, char *argv[])
printf("name as int=%d\n", (int)*name);
// then print them out initialized
printf("numbers: %d %d %d %d\n",
numbers[0], numbers[1],
numbers[2], numbers[3]);
@ -40,7 +44,17 @@ int main(int argc, char *argv[])
name[0], name[1],
name[2], name[3]);
// print the name like a string
printf("name: %s\n", name);
// another way to use name
char *another = "Zed";
printf("another: %s\n", another);
printf("another each: %c %c %c %c\n",
another[0], another[1],
another[2], another[3]);
return 0;
}