breaking ex10

This commit is contained in:
Dan Buch 2011-09-09 09:17:53 -04:00
parent da1b3f8508
commit 5a86af46b0
4 changed files with 34 additions and 1 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ ex6
ex7 ex7
ex8 ex8
ex9 ex9
ex10

View File

@ -1,6 +1,6 @@
CFLAGS=-Wall -g CFLAGS=-Wall -g
EXERCISES = ex1 ex3 ex4 ex5 ex6 ex7 ex8 ex9 EXERCISES = ex1 ex3 ex4 ex5 ex6 ex7 ex8 ex9 ex10
all: $(EXERCISES) all: $(EXERCISES)

10
break-ex10.py Normal file
View File

@ -0,0 +1,10 @@
from __future__ import print_function
import os
import sys
argc = int(sys.argv[1]) if sys.argv[1:] else 23694
command = "valgrind ./ex10 " + " ".join(map(str, range(argc)))
print("command = {}".format(command))
os.system(command)

22
ex10.c Normal file
View File

@ -0,0 +1,22 @@
#include <stdio.h>
int main(int argc, char *argv[])
{
int i = 0;
for(i = 0; i < argc; i++) {
printf("arg %d: %s\n", i, argv[i]);
}
char *states[] = {
"California", "Oregon",
"Washington", "Texas"
};
int num_states = 4;
for(i = 0; i < num_states; i++) {
printf("state %d: %s\n", i, states[i]);
}
return 0;
}