Do you want to use an error msg at all? Anyway, if not, you could just take that part out, and simplify by setting "value" to -1 initially. Then, if scanf() doesn't get a proper number, value will...
Type: Posts; User: MK27
Do you want to use an error msg at all? Anyway, if not, you could just take that part out, and simplify by setting "value" to -1 initially. Then, if scanf() doesn't get a proper number, value will...
Yeah, and using scanf() is fine too. But you need to use the return value of scanf to determine whether or not it retrieved a number. Then you can check that, and do what I did to repeat if scanf()...
Here's an example:
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
/* compile -std=c99 */
float getInput() {