I have a problem reading users input correctly.
User types "A Smaug 23 fire 10" and I need to get the all the information to my code except the first letter 'A'.
char buffer[80];
char *ret = fgets(buffer, 80, stdin)
if (ret == NULL){
break;
}
char name[10],weapon[10];
int attackpoints, hitpoints;
int x = sscanf(ret," %s %d %s %d", name, &attackpoints,weapon,&hitpoints);
This won't work.
How can I skip the A and store users input to the right variables like name = Smaug, attackpoints = 23, weapon = fire, etc?
int x = sscanf(ret," %*s %s %d %s %d", name, &attackpoints, weapon, &hitpoints);where the first specifier with a*reads but ignores (several) chars.