-
scanf
Ok, now I need to read in input through the keyboard. I need to read in for example "mult 40.3" and then I need to parse it to get the mult as a string to convert to uppercase and an double for 40.3 any ideas on how to do this. Should I use scanf or can I even use it or is there something else to use?
Thanks
-
I also need to know when the input is finsished but I can not use ctrl c it has to been inside the loop.
-
One way is to use fgets() followed by sscanf().
Code:
char a[80];
char b[80];
double num;
fgets(a,80,stdin);
sscanf(a,"%s %lf",&b,&num);
You can do this in one step with scanf(), but it's not as safe.
To convert to uppercase, use toupper() in a for-loop.