我試圖通過20「數據庫」結構我做用C傳遞結構數組的元素
這裏的一個是我的原型功能「添加」
void add(struct database test);
我想通過我的數據庫結構和現在我只會把它稱爲「測試」
這裏是我的數據庫結構
struct database
{
char ID[6];
char Duration[3];
};
main()
{
char menu;
struct database employee[20]; // I make 20 employee variables
int a = 0; /*A counter I use to edit certain structs
ie a=2 "employee[a]" = "employee[2]" */
我然後調用這樣的功能:
add(employee[a]);
a++; /*Once it exits this I want it to go to the next employee
variable so I increment the counter */
的實際功能如下所示:
void add(struct database test)
{
static int a = 0;
printf("\nPlease enter a 5 digit employee number: ");
scanf("%s", test[a].ID);
a++
}
而這樣做我得到的錯誤:
錯誤E2094 Assignment.c 64:'運營商+‘類型的參數‘在附加功能(數據庫)詮釋’數據庫」的類型未實現’
它說的錯誤是在
scanf("%s", test[a].ID);
在此先感謝您的幫助,如果我已經格式化了這個錯誤,仍然學習使用堆棧溢出,那麼對不起!
爲什麼不能傳遞結構指針爲**空加(結構數據庫*測試); **,更改添加(員工[一個]); **添加(&employee [a]); **和scanf(「%s」,test [a] .ID);到** scanf(「%s」,test-> ID); ** – user207064