开关情况不工作在turbo c编译器
Switch case not working in turbo c compiler
#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
float a, b, c;
clrscr();
printf("enter value of a");
scanf ("%f", &a);
printf("enter value if b");
scanf("%f", &b);
printf(" a for addition");
printf("b for sub");
scanf("%c", &ch);
switch (ch)
{
case 'a':
c = a + b;
printf("addition=%f", c);
break ;
case 'b':
c = a - b;
printf("nsubtraction=%f", c);
break;
default :
printf ("wrong choice");
}
getch();
}
这是我得到的结果:输入a4的值如果是b4,请输入valuea表示加法b表示子错误选择
问题是连一次开关条件都没有求值。
刷新您的输入缓冲区以消耗缓冲区中剩余的n
。
或者试试
scanf(" %c",&ch);
^
| A space before %c can skip any number of whitespaces
相关文章:
- C/C++编译器通常会删除重复的库吗
- 模板-模板参数推导:三个不同的编译器三种不同的行为
- Win32编译器选项和内存分配
- MSVC多行宏编译器错误
- 静态数据成员的问题-修复链接错误会导致编译器错误
- C++,我收到一个无法理解的编译器错误
- 在线编译器中的分段C++没有打印消息
- 如何解决gcc编译器优化导致的centos双编译器设置中的分段错误
- C/C++预处理器是否可以检测一些编译器选项
- 是否有C++编译器选项允许激进地删除所有函数调用,并将参数传递给具有空体的函数
- C++错误C2600:无法定义编译器生成的特殊成员函数(必须首先在类中声明)
- 我需要知道编译器如何在cpp中使用析构函数
- 编译器如何区分std::vector的构造函数
- CLANG 编译器 说:变量"PTR"可能未初始化
- 告诉c++编译器该参数没有别名
- 如何在 Turbo C++ 3.2 编译器中使用 long long 关键字
- 开关情况不工作在turbo c编译器
- Turbo C++和GCC编译器在指针递增过程中产生不同的结果
- 从 Turbo C++(旧)切换到较新的类似编译器
- 这是turbo c++的另一个可选编译器