Hi
if I have an input in the form: (character)(number)=(number) i.e a7=5.
How would you put it in scanf form?
I've tried:
to no avail. To be extra clear I just want to read in the numbers.Code:scanf("a%d=%d", &getchar, &getnum) == 2
Thanks
Hi
if I have an input in the form: (character)(number)=(number) i.e a7=5.
How would you put it in scanf form?
I've tried:
to no avail. To be extra clear I just want to read in the numbers.Code:scanf("a%d=%d", &getchar, &getnum) == 2
Thanks
i've also tried putting "%*c" in front of "%d", but doesn't work for me.
is (character) always an a? If not, that a in there isn't what you want.Read the format specifiers of scanf. Of course when you hit enter, that will get left behind if you aren't reading that too.Code:scanf( "%*c"%d=%d\n", &num1, &num2 );
Quzah.
Hope is the first step on the road to disappointment.
Genius. thank you![]()
hmm...well for a very simple solution what about:
Code:#include <stdio.h> int main(void){ int x, y; char c; //again just using this for a simple solution scanf("%c%d=%d",&c,&x,&y); //there are other ways..... printf("%d %d", x,y); return(0); }