Skip to content

Instantly share code, notes, and snippets.

@mashcom
Created June 16, 2014 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mashcom/089da2231b677dc00ad8 to your computer and use it in GitHub Desktop.
Save mashcom/089da2231b677dc00ad8 to your computer and use it in GitHub Desktop.
basic forloop statement in c
# 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]);
}
char *states[] ={"harare","byo","mutare","gweru","kwekwe"};
int states_count= 4;
for(i=0;i<=states_count;i++){
printf("the state is %s \n",states[i]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment