Is there anyway to validate floating value? For example, i have a code of
But what if user key in 'A' or "ABC" to it, it will show errors. Anyway to validate that?Code:float a; printf("Please key in a floating value : "); scanf("%f",&a);
Is there anyway to validate floating value? For example, i have a code of
But what if user key in 'A' or "ABC" to it, it will show errors. Anyway to validate that?Code:float a; printf("Please key in a floating value : "); scanf("%f",&a);
hmm ok, just try something already and it works. Thanks n_n
I don't think the compiler takes care of anything. You can test to see whether the scanf call succeeded by checking its return value (it returns the number of items that were successfully matched and assigned).
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.