求助,大神看看这个小程序有没有问题
#include <stdio.h>#include <stdlib.h>
#define QUIT 4
int get_menu_choice(void);
int main()
{
int choice = 0;
int int_var = 0;
float float_var = 0.0;
unsigned unsigned_var = 0;
while(choice != QUIT)
{
choice = get_menu_choice();
if (choice == 1)
{
puts("\nEnter a signed decimal integer (i.e.-123)");
scanf("%d",&int_var);
}
if(choice == 2)
{
puts("\nEnter a decimal floating-point number (e.g.1.23)");
scanf("%f",&float_var);
}
if (choice == 3);
{
puts("\nEnter an unsigned decimal integer (e.g.1.23)");//为什么这一行总是出现?
scanf("%u",&unsigned_var);
}
}
printf("\nYour values are:int:%d,float:%f,unsigned:%u\n ",int_var,float_var,unsigned_var);
return 0;
}
int get_menu_choice(void)
{
int selection = 0;
do
{
puts("\n1-Get a signed decimal integer");
puts("\n2-Get a decimal flosting-point number");
puts("\n3-Get a unsigned decimal integer");
puts("\n4-Quit");
puts("Enter a selection:");
scanf("%d",&selection);
}
while (selection < 1 ||selection >4);
return (selection);
}
上面是程序,看了好几遍都感觉没有错误,但是运行的时候不论输入1还是2做标记的那一行总是出现,用的是CodeBlocks编译的,怀疑是不是编译器有问题