Created
July 10, 2016 18:35
-
-
Save tedwardd/a739d4a08db927390def6c79cbcd8e49 to your computer and use it in GitHub Desktop.
Sample C demo
This file contains hidden or 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
#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 = 5; | |
for(i = 0; i < num_states; i++) { | |
if(states[i]) { | |
//int a = i + 1; | |
//printf("state %d: %s\n", a, states[i]); | |
printf("state %s\n", states[i]); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment