Hello, I'm try to making an address book and I'm stumped on how to store strings entered by the user into a node in the linked list.
This is the struct I have defined.
Code:
struct node{
char name[25];
char address[100];
char phone[25];
struct node *next;
};
.
.
.
Code:
void append(){
struct node *temp = (struct node*) malloc(sizeof(struct node));
if(root == NULL){ // Empty list
printf("Enter Name: ");
fgets(temp->name,25,stdin);
temp->name[strlen(temp->name)-1] = '\0';
}
}
The issue is that the fgets() function is not called instead I return to the options menu I have created in main, and I'm not sure as to why that is happening. I don't want to use scanf because I expect users to enter strings white space i.e name: "John Doe", and I don't want them to enter a string larger than the buffer.
Any help would be nice. Thank You.