Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #define maxCommandLength 80
- #define maxCommands 100
- char command[maxCommands][maxCommandLength];
- int main(int argc, char **argv) {
- if(argc == 1){
- printf("No commands provided");
- return(-1);
- }
- //Initialization
- int commandCurrentCounter = 0;
- int commandTotal = 0;
- //loop to initialize command array
- for(int i = 0; i < maxCommands; i++){
- command[i][0] = '\0';
- }
- //Loop to parse argvs into command array
- for(int i = 0; i < argc; i++){
- char *cur_command = command[commandCurrentCounter];
- if(argv[i][0] != '.'){
- strcat(cur_command, argv[i]);
- strcat(cur_command, " ");
- }
- else{ //is a dot, terminating the command
- if(strlen(cur_command) > 0){
- commandCurrentCounter++;
- }
- }
- }
- if(strlen(command[commandCurrentCounter]) == 0){
- commandTotal = commandCurrentCounter;
- }
- else{
- commandTotal = commandCurrentCounter + 1;
- }
- //Print out Command Array Debug
- for(int i = 0; i < commandTotal; i++){
- printf("command[%d] = \"%s\"\n", i, command[i]);
- }
- //Issue Commands
- //Wait and Restart Loop
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement