From 34505c7200a79d5b09beb3c87429d713837d89d5 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Thu, 8 Sep 2011 22:41:34 -0400 Subject: [PATCH] working version of exercise 9 --- .gitignore | 1 + Makefile | 2 +- ex9.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 ex9.c diff --git a/.gitignore b/.gitignore index f37cd25..f65443b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ ex5 ex6 ex7 ex8 +ex9 diff --git a/Makefile b/Makefile index fe4ee5d..6edda90 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CFLAGS=-Wall -g -EXERCISES = ex1 ex3 ex4 ex5 ex6 ex7 ex8 +EXERCISES = ex1 ex3 ex4 ex5 ex6 ex7 ex8 ex9 all: $(EXERCISES) diff --git a/ex9.c b/ex9.c new file mode 100644 index 0000000..e7feec9 --- /dev/null +++ b/ex9.c @@ -0,0 +1,39 @@ +#include + +int main(int argc, char *argv[]) +{ + int numbers[4] = {0}; + char name[4] = {'a'}; + + printf("numbers: %d %d %d %d\n", + numbers[0], numbers[1], + numbers[2], numbers[3]); + + printf("name each: %c %c %c %c\n", + name[0], name[1], + name[2], name[3]); + + printf("name: %s\n", name); + + numbers[0] = 1; + numbers[1] = 2; + numbers[2] = 3; + numbers[3] = 4; + + name[0] = 'Z'; + name[1] = 'e'; + name[2] = 'd'; + name[3] = '\0'; + + printf("numbers: %d %d %d %d\n", + numbers[0], numbers[1], + numbers[2], numbers[3]); + + printf("name each: %c %c %c %c\n", + name[0], name[1], + name[2], name[3]); + + printf("name: %s\n", name); + + return 0; +}