Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是一个简单的问题,但我看不到:
字符 *s = "f 8.649292" ; 双 d ; sscanf( s, "f %f", &d ) ; printf("d 是 %f\n", d);
为什么d不包含双精度值8.649292?
d
8.649292
哦等等,没关系。d 必须是 a float。
float
为了让它发挥作用,你可以使用%lf双倍
%lf
字符 *s = "f 8.649292" ; 双 d ; sscanf( s, "f %lf", &d ) ; printf("d 是 %lf\n", d ) ;