A
Advocated
This is a part of my code:
<snipped>
#define MAX_LINE_LENGTH 256
typedef struct {
char *name;
void (*function)(void);
} COMMAND;
void progCmd(void);
void prog2Cmd(void);
COMMAND commands[] = {
{"prog1", prog1Cmd},
{"prog2", prog2Cmd}
};
<snipped>
im reading in characters and storing them in an array like:
while((ch = getchar()) != '\n'){
InputString[j] = ch;
line[k] = ch;
j++;
k++;
}
InputString[j] = '\0';
line[k] = '\0';
This is working fine. An example of running my program would be:
$ hello world
this would print
token0 is hello
token1 is world
Is there a way, so i can check if token0 is prog1? if you get what i mean?
the aim is so, if token0 is not prog1 or prog2, or not something else in the
commands array, then printf("exit") or something.
Cheers for any ideas
<snipped>
#define MAX_LINE_LENGTH 256
typedef struct {
char *name;
void (*function)(void);
} COMMAND;
void progCmd(void);
void prog2Cmd(void);
COMMAND commands[] = {
{"prog1", prog1Cmd},
{"prog2", prog2Cmd}
};
<snipped>
im reading in characters and storing them in an array like:
while((ch = getchar()) != '\n'){
InputString[j] = ch;
line[k] = ch;
j++;
k++;
}
InputString[j] = '\0';
line[k] = '\0';
This is working fine. An example of running my program would be:
$ hello world
this would print
token0 is hello
token1 is world
Is there a way, so i can check if token0 is prog1? if you get what i mean?
the aim is so, if token0 is not prog1 or prog2, or not something else in the
commands array, then printf("exit") or something.
Cheers for any ideas