鱼C论坛

 找回密码
 立即注册
查看: 3298|回复: 3

初学C语言,有个小问题求大佬解答。关于scanf问题。

[复制链接]
发表于 2019-10-16 17:15:43 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
#include <stdio.h>
int main(void)
{
    float fl_num;

    printf("Enter a floating-point value:");
    scanf("%f\n", &fl_num);
    printf("fixed-point notation: %f\n", fl_num);
    printf("exponential notation: %e\n", fl_num);
    printf("p notation: %a\n", fl_num);

    return 0;
}


这个是我的代码。
为什么在scanf这一行中%f后面加上换行,需要这样输入才会展示出结果,
Enter a floating-point value:64.25
1   
fixed-point notation: 64.250000
exponential notation: 6.425000e+01
p notation: 0x1.01p+6

难道不应该是输入64.25后变成这样吗
Enter a floating-point value:64.25


fixed-point notation: 64.250000
exponential notation: 6.425000e+01
p notation: 0x1.01p+6
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-10-14 03:17

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表