This is my function in my main
int get_name(void){
char name;
printf("Please enter the student name: ");
scanf("%s", &name);
return name;
}
I initialize my struct which is
typedef struct{
char name[MAXSTRING];
int id;
}student;
by doing
name = get_name();
number= get_id();
student s1 = {.name=name , .id=number};
printf("id is %d\n",s1.id);
printf("name is %s\n", s1.name);
But what i get as a return is the first character of the string i enter. MAXSTRING is defined in my student.h as
#define MAXSTRING 20
I am pretty sure i have to modify my name variable in some way but i tried a lot of things and nothng worked. Also is it better to use fgets in this scenario?