Extract inputs from a pointer to array of characters in C / C++
- by user2066884
I am writing a command line utility but I cannot find a way to store the commands and arguments. so far I have the following but I get a Segmentation fault:
int main(void)
{
    char *command;
    char *args[MAX_LINE/2 + 1]; 
    int should_run = 1;
    do{
         cout << "cmd> ";
         int counter = 0;
         while(cin >> command) {
             strcpy(args[counter],command);
             counter++;
         }
        cout << args[0] << "\n";
    }  
}