9
Dies ist ein einfaches Problem, aber ich kann es nicht sehen:sscanf für Doppel
char *s = "f 8.649292" ; double d ; sscanf(s, "f %f", &d) ; printf("d is %f\n", d) ;
Warum ist d
nicht den doppelten Wert enthält 8.649292
?
'% lf' wird zum Scannen eines Doppel mit' scanf' benötigt verwenden könnte, aber es ist falsch '% lf' zu verwenden, um mit' printf' . Benutze einfach '% f'. –
@R .. [Erklärung Ihres Kommentars] (http://stackoverflow.com/questions/210590/why-does-scanf-need-lf-for-double-when-printf-is-okay-with-just- f) – bobobobo