-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
*有一些錯誤*是絕對無用的問題描述。我們無法看到您的屏幕或閱讀您的想法。 **具體說明**發生了什麼*錯誤*或問題,並提出有關該問題的具體問題**。通過對問題進行編輯並在問題所在的位置添加細節,而不是置身於評論噪音中。 –