c - 如何通过按 'Enter' 键而不是任何字母键来结束 while 循环?

标签 c

我想通过按“Enter”键而不是任何字母键来结束 while 循环。我不知道我该怎么做。 我已经这样做了,如果输入不是数字它将退出,但我希望输入是“Enter”键。

void main (void)
            {
                float f;
                float total=0.0;
                printf("Enter numbers to be add: ");
                while (scanf("%f",&f)==1)
                    {
                        total=total+f;
                        printf("Enter another # to be add: ");
                                        scanf("%1.0f",&f);
                    }
                printf("Addition Total = %1.0f",total);
            }

最佳答案

关于c - 如何通过按 'Enter' 键而不是任何字母键来结束 while 循环?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8999057/

相关文章:

c - sizeof(bitfield_type) 在 ANSI C 中合法吗?

c - 如何在C中实现Z系数?

c - 在C语言游戏中使用鼠标控制

c - union 结构的 parser.y 错误

c - 在 C 中使用第二次调用 send() 时出现问题

c - 如何包含自定义 C 库

mysql - 跨多个源文件的共享类型 - C

c - 如何在宏(或替代方案)中#define

c - 我是否要转换 malloc 的结果?

c - 从管道读取: How to handle the return values in c?