| [ CnUnix ] in KIDS 글 쓴 이(By): terzeron (microkid) 날 짜 (Date): 2002년 3월 6일 수요일 오전 01시 16분 29초 제 목(Title): Re: glib에서 링크리스트쓰기.. 그건 g_slist_append가 계속 고정된 주소값을 받아들이기 때문에 생기는 문제입니다. int main() { GSList *list = NULL; char inbuf[20]; char *temp; do { fgets(inbuf, 20, stdin); temp = strdup(inbuf); if (inbuf[0] == '.') break; list = g_slist_append(list, temp) ; } while (inbuf[0] != '.'); g_slist_foreach(list, (GFunc) PrintNames, NULL); return 0; } fgets를 쓰셨으니 newline 처리는 알아서 해주셔야겠죠? |