c - 不接受输入第二次进入不采用 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;}
解决方案
推荐阅读
- java - 如何从android中的原始有效负载中提取价值?
- powershell - PowerShell cmdlet Set-ADComputer 和 Get-ADComputer 是否在 OU=COMPUTER 之外工作?
- node.js - grep -e 命令返回匹配数据
- python - 在 Pterodactyl 控制面板中使用 Python 和 Account API 密钥获取服务器状态
- azure-ad-graph-api - 在 Flow 中传递获取值
- c# - 如何实现 BindableBase 到 EF6 模型?
- python - 为什么在 jupyter notebook 中调用 plt.figure() 时,会出现两个图形?
- c++ - 从对中分配向量
- angular - CKEditor 右键选择剪切不会调用更改事件
- postgresql - 如何将 JSON 数组转换为 PostgreSQL 中的 Postgres 数组?