Hey all,
I'm relatively new to C, although I'm very familiar with PHP, so I'm aware of the general constructs of C. However...I'm having a small problem with an array of characters in a struct. When scanf'ing to the struct the array is ending after any 'spaces' in the string. For example if I were to enter my full name, it would simply display "Richard".
This struct / string is also a part of a linked list, so I'm not sure if this might be causing a problem?
Heres the overall view of whats happening...
Thanks in advance,Code:typedef struct T_Lecturer { char Name[25]; } LecturerInfo; typedef struct T_PtrNode { LecturerInfo Lecturer; struct T_PtrNode *Next; } LecturerNode; int main() { LecturerNode *NewEntry; NewEntry = malloc(sizeof(*NewEntry)); if (NewEntry != NULL) { printf("Name: "); // John Smith scanf("%s", NewEntry->Lecturer.Name); } printf("%s", NewEntry->Lecturer.Name); // John }
Richard.