Is there a way to read a c-string and then an int with a single scanf in C?
Posted
by
Aux
on Stack Overflow
See other posts from Stack Overflow
or by Aux
Published on 2011-01-31T07:01:49Z
Indexed on
2011/01/31
7:26 UTC
Read the original article
Hit count: 109
Hey, I'm trying to get this function to get the following output with the listed input, the "..." is where I'm not sure what to write:
void Question8(void)
{
char sentence[100];
int grade;
scanf(….);
printf("%s %d", sentence, grade);
}
Input:
My CS Grade is 1000
Output:
My CS Grade is 100
However, the kicker is that I need the scanf to read a c-string and then an int with a single scanf command, is this even possible?
© Stack Overflow or respective owner