본문/내용
1. 코드
`);while (fgets(input, sizeof(input), stdin)) {char token = strtok(input, ` \n`);while (token != NULL) {if (strcmp(token, `exit`) 0) {break;}addWord(&head, token);token = strtok(NULL, ` \n`);}if (strcmp(token, `exit`) 0) {break;}}``` 연결리스트에 추가된 단어와 그 출현 횟수를 출력하는 함수 `printWords`를 정의한다. 이 함수는 리스트를 순회하며 각 노드의 단어와 카운트를 출력한다. 리스팅의 끝을 확인하기 위해 `current` 포인터가 `NULL`이 될 때까지 반복한다. \n`);printWords(head);return 0;} void printWords(Node head) {Node current = head;while (current != NULL) {printf(`%s %d\n`, current-`word, current-`count);current = current-`next;}}``` 마지막으로, 프로그램이 종료되기 전에 메모리를 해제하는 함수를 구현하여 동적 메모리 할당으로 생성된 노드를 모두 삭제해야 한다. `freeList` 함수를 사용하여 리스트를 순회하면서 각 노드를 해제한다. ```cvoid freeList(Node head) {Node current = head;Node next;while (current != NULL) {next = current-`next;free(current);current = next;}}``` 이렇게 구성된…