Image

Imagejizmunci wrote in Imagecpp

shell

Hello again, I have only just got round to doing the shell assignment. The first problem I have run into is that of reading in and parsing commands. The whole thing's meant to run in an infinte loop but this has lead me to getting stuck in a loop.

The basic structure of this bit is meant to be like:
int ii;
char cmd[100];
char* args[100];

while (1)
{
cout << "Hi Class $ ";
cin.getline(cmd, 100);

ii = 0;
if ((args[ii++] = strtok(cmd, " \t")) == NULL)
continue;

while((args[ii++] = strtok(NULL," \t")) != NULL)
;

Any suggestions on how to get this to work?