I'm looking to get the user's input all at once by using scanf in a while loop. The input will most likely be in a form that contains both characters and float numbers: E.g. 2 + 3.4 * 5, and I want to store the number and character into a separate array (for further processing via functions)
This is what I've come up with so far:
while (scanf(" %f", &num1) == 1 || scanf(" %c ", &op) == 1) {
printf("%f ----> %c", num1, op);
}
but any character that I enter is automatically converted to a 'u' and my numbers are printed twice if I enter more than one number. Furthermore, I'm not sure how to get out of the while loop. (I tried throwing a break below printf, but that only allowed two inputs to be read)
Any idea how I can make this work?