E
ern
//I used strtok() like this:
fgets(userCommand, MAX_COMMAND_SIZE, stdin);
g_UserCommands[0] = strtok(command, " ");
while(g_UserCommands != NULL){
i+=1;
g_UserCommands = strtok(NULL, " ");
}
//Now I want to use strcmp() like this:
if(strcmp(g_UserCommands[0], "script")==0){
return (executeScript(arg1));
}
/* Unfortuantely, I'm not getting desired results, probably because
the strings in g_UserCommands are not null terminated. Any suggestions
on a better way to get null terminated strings in g_UserCommands or
suggestions in general? I was hoping for a function that does what
strtok() does, but also providing null termination.
Thanks!
*/
fgets(userCommand, MAX_COMMAND_SIZE, stdin);
g_UserCommands[0] = strtok(command, " ");
while(g_UserCommands != NULL){
i+=1;
g_UserCommands = strtok(NULL, " ");
}
//Now I want to use strcmp() like this:
if(strcmp(g_UserCommands[0], "script")==0){
return (executeScript(arg1));
}
/* Unfortuantely, I'm not getting desired results, probably because
the strings in g_UserCommands are not null terminated. Any suggestions
on a better way to get null terminated strings in g_UserCommands or
suggestions in general? I was hoping for a function that does what
strtok() does, but also providing null termination.
Thanks!
*/