save_history(history_first,tok);
    history_cur = history_first;
    if(history_first==NULL)
     printf("fuck2\n");
    printf("%s\n",history_first->command);

   }
   else
    save_history(history_cur,tok);
  }
  if(print==1)
   print_history(history_first);
 }

 return 0;
}


void save_history(struct HISTORY *cur,char *command)
{
 struct HISTORY *temp;
 printf("2\n");
 if(cur==NULL) // 첫 번째 입력일 경우
 {
  printf("4\n");
  cur = (struct HISTORY*)malloc(sizeof(struct HISTORY));
  strcpy(cur->command,command);

  if(cur==NULL)
   printf("fuck\n");
  printf("%s\n",cur->command);


소스의 일부분입니다.
위쪽의 굵은글씨에서 save_history를 호출해서 malloc을 해주고 command라는 char를 넣어주는데,
함수 안에서는 NULL 검사도 통과하고 출력도 제대로 되지만
함수가 끝나고
if(history_first==NULL)
printf("fuck2\n");
printf("%s\n",history_first->command);
이 부분에서는 NULL검사 통과 못하고 printf에서 세그멘테이션 에러가 뜨는데

이유가 뭔가요; 함수 리턴형이 void라서 그런건 아닐거고 이해가 안됨 ㅠㅠ