Итак, я пытаюсь вызвать функцию в своей основной функции в моей функции переключения, и она говорит мне «ожидаемый» («для функционального стиля или построения типа». я делаю неправильно здесь вызывает эту ошибку? Я не могу понять это. Спасибо.Ожидаемый '(' для функционального стиля или конструкции типа
#include <stdio.h>
#include <stdlib.h>
#define ARRAY_SIZE 6
#include <string.h>
typedef struct
{
char name[100];
unsigned int accountId;
float accountBalance;
int yearJoined;
} BankingInfo;
void createTestData(BankingInfo inventory[]){
strcpy(inventory[0].name, "Alex");
inventory[0].accountId = 1001;
inventory[0].accountBalance = 2390;
inventory[0].yearJoined = 2001;
strcpy(inventory[1].name, "Bill");
inventory[1].accountId = 1003;
inventory[1].accountBalance = 10000;
inventory[1].yearJoined = 2012;
strcpy(inventory[2].name, "Craig");
inventory[2].accountId = 1004;
inventory[2].accountBalance = 500;
inventory[2].yearJoined = 1994;
strcpy(inventory[3].name, "David");
inventory[3].accountId = 1008;
inventory[3].accountBalance = 5836;
inventory[3].yearJoined = 2013;
strcpy(inventory[4].name, "Eric");
inventory[4].accountId = 1016;
inventory[4].accountBalance = 90;
inventory[4].yearJoined = 1999;
strcpy(inventory[5].name, "Felix");
inventory[5].accountId = 1032;
inventory[5].accountBalance = 5703;
inventory[5].yearJoined = 2003;
}
void outputTable(BankingInfo inventory[], int size){
int i;
printf("Names\tID\t\tAccount Balance\t\tYear Joined\n");
for (i = 0; i < ARRAY_SIZE; i++) {
printf("%s\t%u\t %.2lf\t\t\t%i\n",
inventory[i].name,inventory[i].accountId,
inventory[i].accountBalance, inventory[i].yearJoined);
}
}
void searchById(BankingInfo inventory[], int size, int id){
unsigned int enteredId;
int i;
printf("Enter ID number: ");
scanf("%u", &enteredId);
for (i = 0; i < ARRAY_SIZE; i++) {
if (inventory[i].accountId == enteredId) {
printf(inventory[i].name,inventory[i].accountId,
inventory[i].accountBalance, inventory[i].yearJoined);
}
}
}
void searchByYear(BankingInfo inventory[], int size, int year){
unsigned int enteredYear;
int i;
printf("Enter year joined: ");
scanf("%u", &enteredYear);
for (i = 0; i < ARRAY_SIZE; i++) {
if (inventory[i].yearJoined == enteredYear) {
printf(inventory[i].name,inventory[i].accountId,
inventory[i].accountBalance, inventory[i].yearJoined);
}
}
}
int main(void){
int choice;
BankingInfo inventory[ARRAY_SIZE];
createTestData(inventory);
outputTable(inventory, ARRAY_SIZE);
do{
printf("Enter 1 to search by ID\n");
printf("Enter 2 to search by year joined\n");
printf("Enter 3 to finish\n");
switch (choice) {
case 1:
searchById(inventory, ARRAY_SIZE, int id);
break;
case 2:
searchByYear(inventory, ARRAY_SIZE, int year);
break;
case 3:
break;
default:
printf("Not a valid choice\n");
break;
}
}while (choice != 3);
return 1;
}
Вы можете отметить номер строки ошибки? – wimh