Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- }
Add Comment
Please, Sign In to add comment