I defined my list like this:
struct student {
char vname[30]; // Vorname
char nname[30]; // Nachname
int mnr; // Matrikelnummer
char adresse[50]; // Adresse
int pfkur; // Anzahl der bereits belegten Pflichtkurse
struct student *next; //Zeiger auf Nachfolger
struct student *prev; // Zeiger auf Vorgänger
};
typedef struct student student;
typedef struct student *pstudent;
Now I'm having trouble with scanning strings with blank spaces such as "van Helsing"
My implementation for scanning in the things into the list is this:
pstudent allocate(void){
pstudent elp;
elp = (pstudent)malloc(sizeof(*elp));
if (elp == NULL){printf("ERROR: malloc"); exit(1);}
elp -> next = NULL;
return elp;
} /* allocate */
elp = allocate();
printf("\n Vorname:\t\t "); scanf("%s", elp -> vname); // Vorname
printf(" Nachname:\t\t "); scanf("%s", elp -> nname); //Nachname
printf(" Matrikelnummer:\t\t "); scanf("%d",&(elp -> mnr));
printf(" Adresse:\t\t "); scanf("%s", elp -> adresse); // Adresse
printf(" Pflichtkurse:\t\t "); scanf("%d", &(elp -> pfkur)); //
elp -> next = studentlist;
studentlist = elp;
These are just code snippets out of a bigger project so if you need any context feel free to ask but I think the sufficient informations are provided. I also know that there are missing things for example the complete connection of the list and so on.
I'm looking for a way to scan strings into vname, nname and adresse with blank spaces in them. Right now the whole programm gets very buggy when I'm trying to do that.
Thank you in advance.