The error is referencing the following line of code:
tenant[i].name = get_string("Enter the residents name: ");
and has an arrow pointing at the period . between tenant[i] and name. I am not sure what I am missing.
typedef struct {
string name;
int apt;
} tenant;
int n;
int numres(void);
string nameres(int numres);
int apt(int numofres);
int main(void) {
int numres(void);
tenant tenants[n];
string nameres(int n);
int apt(int n);
for (int m = 0; m < n; m++) {
printf("Resident %s resides in apt# %i\n",
tenants[m].name, tenants[m].apt);
}
return 0;
}
//this function prompts the user for the number of residents
int numres(void) {
do {
n = get_int("Enter the number of residents: ");
} while (isalpha(n) != 0 || isspace(n) != 0);
return n;
}
// this function prompts the user for the residents names.
string nameres(int numres) {
int i = 0;
do {
tenant[i].name = get_string("Enter the residents name: ");
return tenant[i].name;
i++;
} while (i < numres);
}
// this function prompts the user for the residents apt number
int apt(int numofres) {
for (int i = 0; i < numofres; i++) {
tenant[i].apt = get_int("Enter residents apt number: ");
return tenant[i].apt;
}
}