리눅스 glib에서 g_list 를 이용한 배열을 만들고 그 배열을 화면에 printf 할수있는 g_list_함수좀 알려주세요

rkarkd의 이미지

숫자 및 문자를 입력받아서
GList이용하여 스택을 쌓는 프로그램을 만들려고 합니다.
어찌어찌 여기까지는 만들었는데
선언된 add 기능에서 숫자 1개만 넣으면 다시 command 입력으로 돌아가더라구요
이걸 어떻게 해결해야하나요?
그리고 입력된 변수들을 GList 를 이용해서 모두 볼수있는방법이 있을까요?
GList를 이용하지 못한다면 다른방법이라두요
입력이 되는지 않되는지 확인하고싶은데 방법을 모르겟습니다.

#include <stdio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
 
int main()
 
{
	int i;                         //  int i
	char j,a[1024],choice[10];     //a=add, choice=fungtion choice
 
 
	GList *head = 0;  
   GList *cur = 0;
 
 
 
 
   while(strcmp(a,"999")!=0)
   {
	printf("Enter command :"); //messeage
	scanf("%s", &choice);
 
 
		if(strcmp(choice, "add")==1);
		{	
		printf("Enter word to add :");
		scanf("%s", &a[i++]);
 
		char *temp = (char *)malloc(sizeof(char));
		*temp = &a[i++];
 
		head = g_list_append(head, temp);
 		temp++;
 
 	   }
 
		if(strcmp(choice, "showall")==1);
		{
		head = g_list_index (head, temp);
		printf("%s", head);
      }
 
		if( strcmp(choice, "search")==1);
		{
 
		}
		if( strcmp(choice, "delete")==1);
		{
 
		if(strcmp(choice, "quit")==1);
		{
			exit(0);                    //quit 
		}
 
		}
return 0;
}

주석처리된 부분은 아직 고민하고있습니다.