Part of my file:
The code is working fine. However, I'd like the user to be able to type "grab butter" or "grab toast" or "grab [item]". Can I still use strcmp to read in grab but store the second word in a char name[10]? Or is there something much better to use than strcmp?Code:int main(void) { int done = 0; char line[300]; do { printf("> "); fgets(line, 300, stdin); line[strlen(line) - 1] = '\0'; if(strcmp(line, "area items") == 0) { areaItems(current, startPtr); } if(strcmp(line, "commands") == 0) { commands(); } //...etc }while(! done); return(0); }
Hope that makes sense. Thanks



LinkBack URL
About LinkBacks



