This is part of the code from a shell program I'm working on:
I'm getting 5 "incompatible types in assignment" errors in get_input(), one on each line with cmd.(whatever)Code:struct c { char command[10]; char argument1[40]; char argument2[40]; }; struct c get_input(struct c cmd) /* Gets input from keyboard, and splits it up into command & arguments */ { char input[92]; /* Full command string: command + any arguments */ printf(">: "); /* Print the prompt */ gets(input); /* Get input */ cmd.command = strtok(input, " "); /* Get command */ if ((cmd.argument1=strtok(NULL, " ")) == NULL) /* Get first argument */ { cmd.argument1 = "\0"; /* if there isn't one, make null string */ } if ((cmd.argument2=strtok(NULL, " ")) == NULL) /* Get second argument */ { cmd.argument2 = "\0"; /* if there isn't one, make null string */ } return cmd; }
As far as I can tell, it's complaining about me trying to put strings into the string variables in the 'cmd' structure, but I can't see why. Is there something I've overlooked? (I've included the structure defenition too, in case there's something wrong in there.)