I'm a newbie to C, and I have been testing my program out in Fedora, using gcc and gdb to debug. I have a program that takes input from the user. If the first string entered is "create" then I take a look at the second command, and if that's "object" then I proceed to the createObject function.
Hopefully my code will make this a bit clearer:
static void parseCmd(char **input) {
if(!strcmp(input[0], "create")) {
if(!strcmp(input[1], "object")) {
if(input[2] && strcmp(input[2], ""))
createObject(input[2]);
else
printf("Object needs a name\n");
}
else
printf("Command needs more parameters\n");
}
else
printf("Command not recognized\n");
}
When I test entering just "create object" (no space after object, just the ENTER key)
In Linux it prints "Object needs a name"
But in windows the program crashes, it just hangs. How could I change the code to make it behave the same way as it does in Linux?