prev up next   top/contents search

comp.lang.c FAQ list · Question 12.13

Q: Why doesn't this code:

double d;
scanf("%f", &d);

A: Unlike printf, scanf uses %lf for values of type double, and %f for float. [footnote] %f tells scanf to expect a pointer-to-float, not the pointer-to-double you gave it. Either use %lf, or declare the receiving variable as a float. See also question 12.9.

prev up next   contents search
about this FAQ list   about eskimo   search   feedback   copyright

Hosted by Eskimo North