首页 > 解决方案 > 不接受输入第二次进入不采用 emp 2 名称的 c

问题描述

它只是第二个打印语句“输入 emp2 的名称”,但不接受输入,而是跳到第二个打印语句。我得到的输出: 输入emp1的名字: Shivanshu 输入emp1的薪水:20000 输入代码:101 输入emp2的名字: 输入emp2的薪水:

注意:- scanf() 也有同样的问题。

#include<stdio.h>
#include<conio.h>
struct employee{
int salary;
int code;
char name[10];
};
int main(){
struct employee e1,e2,e3;

printf("Enter the name of the emp1: ");
gets(e1.name);
printf("Enter the salary of emp1: ");
scanf("%d",&e1.salary);
printf("Enter the code: ");
scanf("%d",&e1.code);

printf("Enter the name of the emp2: ");
gets(e2.name);
printf("Enter the salary of emp2: ");
scanf("%d",&e2.salary);
printf("Enter the code: ");
scanf("%d",&e2.code);

printf("Enter the name of the emp3: ");
gets(e3.name);
printf("Enter the salary of emp3: ");
scanf("%d",&e3.salary);
printf("Enter the code: ");
scanf("%d",&e3.code);




return 0;}

标签: c

解决方案


推荐阅读