so im tryna save input from stdin to a node. but every time i run the loop it resets whats in my node. idk if that makes sense.. heres my code..
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct queue_node
{
char word[11];
struct queue_node *next;
} node;
struct queue_node *make_list(void);
struct queue_node *add_node(void);
void accept_input (struct queue_node *, char[]);
int menu();
int main(void)
{
int choice = 0;
struct queue_node *start; //pointer to start of list
do
{
choice = menu();
if(choice == 1)
{
start = make_list();
continue;
}
else
{
printf("pee");
continue;
}
} while ( choice != 5 );
return 0;
}
int menu()
{
int choice;
printf("Enter a Number Based on what you would like to do:\n");
printf(" 1. Add a Word \n 2. Delete a Word \n 3. Display the Data in Queue Order \n 4. Search the Queue for a Word \n 5. Quit \n");
scanf("%i", &choice);
return choice;
}
struct queue_node *make_list(void)
{
char buffer[11];
struct queue_node * start = NULL, * current, * new;
int j;
for (j=0;j<2;j++)
{
new = add_node();
if (start==NULL)
{
start = current = new;
}
else
{
current->next = new;
current = current->next;
}
accept_input (current, buffer );
}
printf("%s<current>", current->word);
printf("%s<start>", start->word);
return start;
}
void accept_input (struct queue_node * local_node, char str[])
{
int i;
char input[11];
printf ("enter something\n");
scanf ("%s",&input);
strcpy(str, input);
sscanf(str,"%s",local_node->word);
return;
}
struct queue_node * add_node (void)
{
struct queue_node * new_ptr; // local pointer
new_ptr = (struct queue_node *) malloc (sizeof (struct queue_node));
new_ptr->next = NULL;
return new_ptr;
}