> My understanding of scanf() is limited because I do not have the MSDN library.
Without a decent reference, any new function you come across will leave you guessing.
Didn't something come with your compiler?
As mentioned already (partly at least), use sscanf() to pull the input apart.
Code:
#include <stdio.h>
int main ( ) {
char buff[BUFSIZ];
while ( fgets( buff, BUFSIZ, stdin ) != NULL ) {
int drop;
if ( sscanf( buff, "drop %d", &drop ) == 1 ) {
printf( "You dropped item %d\n", drop );
} else {
printf( "I don't understand %s", buff );
}
}
return 0;
}
Simply add more else if constructs to match all your other commands.