Last active
April 17, 2018 18:34
-
-
Save lane-s/8ed64513892ee420fe9df299a73b7dd9 to your computer and use it in GitHub Desktop.
This file contains 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
int fillArr(Command* arr){ | |
int actual_num_commands = 6; | |
int i; | |
for(i = 0; i < actual_num_commands; i++){ | |
arr[i].name = "foo"; | |
arr[i].args[0] = "foo"; | |
arr[i].args[1] = "bar"; | |
} | |
return actual_num_commands; | |
} | |
int printArr(Command* arr, n){ | |
int i; | |
for(i = 0; i < n; i++){ | |
printf("Command %d is %s\n", arr[i].name); | |
} | |
return 0; | |
} | |
int main(){ | |
int max_commands = 50; | |
Command* cmdArr = calloc(max_commands, sizeof(Command)); | |
int n = fillArr(cmdArr, max_commands); //Equivalent to the parsing function | |
if(n > 0){ | |
printArr(cmdArr, n); //Equivalent to the function that does the interpreting | |
} | |
free(cmdArr); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment