im total beginner in c , here problem. in c++ bad input(not unsigned int) way:
long double c; cin >> c; if (c == (unsigned int) c) { cout<<"ok"; } else cout<<"not ok";
however when learning c i'm trying same way, not work:
long double c; scanf("%lf", &c); if (c == (unsigned int) c) { printf("ok\n"); } else printf("not ok\n");
any advice on how fix it? task using scanf , no strings. don't want negative , float numbers inputted. why doesnt work?
the conversion directive %lf
scanning double
s.
to scan long double
s, use %lf
, upper case l
.
from specification of fscanf
(7.21.6.2)
l (ell) specifies following d, i, o, u, x, x, or n conversion specifier applies argument type pointer
long int
orunsigned long int
; that following a, a, e, e, f, f, g, or g conversion specifier applies argument type pointerdouble
; or following c, s, or [ conversion specifier applies argument type pointerwchar_t
.l specifies following a, a, e, e, f, f, g, or g conversion specifier applies argument type pointer
long double
.
Comments
Post a Comment