I am new to C programming, and I don't know what I'm doing wrong.
I have a main method and I have made a struct.
I need to make an array in main of that struct and then assign the values via scanf in the for loop.
My program compiles without an error, but after entering anything in the console, it throws exceptions that I do not understand. The exceptions that I get are:
Warning C4477 'scanf_s' : format string '%s' requires an argument of type 'char *', but variadic argument 1 has type 'char **'
Warning C4473 'scanf_s' : not enough arguments passed for format string
Here is how my code looks like:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
struct Employee {
char *ccFirstName;
char *ccLastName;
int iAge;
};
int main(void) {
struct Employee sExampleEmployee[3];
for (int i = 0; i < 3; i++) {
printf("Geben Sie den Namen :");
sExampleEmployee[i].ccFirstName = scanf_s("%s", &sExampleEmployee->ccFirstName);
sExampleEmployee[i].ccLastName = scanf_s("%s", &sExampleEmployee->ccLastName);
sExampleEmployee[i].iAge = scanf_s("%d", &sExampleEmployee->iAge);
}
for (int i = 0; i < 3; i++) {
printf("First name of the employee: %s", sExampleEmployee[i].ccFirstName);
printf("Last name of the employee : %s", sExampleEmployee[i].ccLastName);
printf("Age of the employee: %d", sExampleEmployee[i].iAge);
}
return EXIT_SUCCESS;
}
\nat the end of each of theprintfformat strings.