-3
我目前正在做一项工作,我必须使用的结构是c到WAP采取100名员工的输入作为名称,年龄和工资,并显示它作为输出,但我有一些错误,即时通讯无法修复。C代码错误使用结构
PS:新手。
#include <stdio.h>
#define SIZE 100
struct employee
{
int empno;
char name[100];
int age, salary;
} e[100];
int main(void)
{
struct employee emp[100]
int i, n;
clrscr();
printf("Enter the number of employees\n");
scanf("%d",&n);
for (i=0;i<n;i++)
{
printf("\n Enter employee number : ");
scanf("%d",&e[i].empno);
printf("\n Enter name of employee : ");
scanf("%s",&e[i].name);
printf("\n Enter age of employee : ");
scanf("%d",&e[i].age);
printf("\n Enter salary of employee : ");
scanf("%d",&e[i].salary);
}
printf("\n Emp. No. Name \t Age \t Salary \n\n");
for (i=0;i<n;i++)
printf("%d \t %s \t %d \%d \n",
e[i].empno,e[i].name,e[i].age,e[i].salary);
return 0;
}
,这是错误
prog.c: In function ‘main’:
prog.c:15:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’
int i, n;
^~~
prog.c:16:9: warning: implicit declaration of function ‘clrscr’ [-Wimplicit-function-declaration]
clrscr();
^~~~~~
prog.c:25:33: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[100]’ [-Wformat=]
scanf("%s",&e[i].name);
^
护理会比 “一些错误” 更具体的? – interjay
this:prog.c:在函数'main'中: prog.c:15:9:错误:预计'=',',';','asm'或'__attribute__'在'int'之前 int我,n; ^ ~~ prog.c:16:9:warning:隐式声明函数'clrscr'[-Wimplicit-function-declaration] clrscr(); ^ ~~~~~ prog.c:25:33:warning:格式'%s'需要'char *'类型的参数,但参数2的类型为'char(*)[100]'[-Wformat = ] scanf(“%s”,&e [i] .name); ^ – Ron
*有一些错误*是绝对无用的问题描述。我们无法看到您的屏幕或阅读您的想法。 **具体说明**发生了什么*错误*或问题,并提出有关该问题的具体问题**。通过对问题进行编辑并在问题所在的位置添加细节,而不是置身于评论噪音中。 –