STORING ARRAY NAMES TO QUEUE DATA STRUCTURE

I made a program that accepts single characters and numbers only in queue data structure. now, i want my program to accept names and stored it in queue with this format:

angel-->jade-->anthony-->NULL

whats wrong with my program that when ever i i enter angel it will display unknown character then NULL..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
void main()
{
   QueueNodePtr headPtr=NULL;
   QueueNodePtr tailPtr=NULL;
   int choice;
   char item[10], items;
   clrscr();

   instructions();
   printf("?");
   scanf("%d", &choice);
   while(choice!=3){
   switch(choice){
      case 1:
	 printf("Enter a character: ");
	 scanf("\n%s", &item);
	 enqueue(&headPtr, &tailPtr, item);
	 printQueue(headPtr);
	 break;
      case 2:
	 if(!isEmpty(headPtr)){
	    items=dequeue(&headPtr, &tailPtr);
	    printf("%c has been dequeued.\n", items);
	 }
	 printQueue(headPtr);
	 break;
      default:
      printf("invalid choice.\n\n");
      instructions();
      break;
   }

   printf("\n\n?");
   scanf("%d", &choice);
   }
   printf("End of run.\n");
   getch();
}


this is the main program..i really think i had the problem in this part..what should be my proper declaration
Last edited on
scanf("\n%s", &item); You don't need & here ?
Topic archived. No new replies allowed.