1. Lucian Brănescu-Mihăilă
  2. lcthw

Commits

Lucian Brănescu-Mihăilă  committed f063cc9

Ex10.

  • Participants
  • Parent commits 5743701
  • Branches default

Comments (0)

Files changed (3)

File Makefile

View file
 CFLAGS=-Wall -g
 
-programs = ex1 ex3 ex4 ex5 ex6 ex7 ex8 ex9
+programs = ex1 ex3 ex4 ex5 ex6 ex7 ex8 ex9 ex10
 
 all: $(programs)
 

File ex10.c

View file
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+    int i = 0;
+
+    // go through each string in argv
+    // why am I skipping argv[0]?
+    for(i = 1; i < argc; i++) {
+        printf("arg %d: %s\n", i, argv[i]);
+    }
+
+    // let's make our own array of strings
+    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;
+}

File ex9.c

View file
             numbers[2], numbers[3]);
 
     printf("name each: %c %c %c %c\n",
-            name[0], numbersame[1],
+            name[0], name[1],
             name[2], name[3]);
 
     printf("name: %s\n", name);