연결리스트 에러좀 봐주세요 ㅠ
에가득
질문 제목 :
연결리스트 에러좀 봐주세요 ㅠ
연결리스트를 짰는데 리스트 출력이 되질 않습니다.
질문 내용 :
#include stdio.h
#include stdlib.h
#include string.h
typedef struct student
{
int age;
int number;
struct Node * next;
}Node;
typedef struct {
Node * head;
}Node_h;
Node * head;
Node_h * create(void){
Node_h * L;
L = (Node_h*)malloc(sizeof(Node_h));
L-head = NULL;
return L;
}
Node * make_node()
{
Node * node;
node = (Node *)malloc(sizeof(Node));
node-next = NULL;
return node;
}
void link_at_the_end_of_thelist(Node *new_node)
{
if (head == NULL)
head = new_node;
else
{
Node * ptr = head;
while (ptr -next != NULL)
{
ptr = ptr-next;// 에러남(4IntelliSense: Node * 형식의 값을 Node * 형식의 엔터티에 할당할 수 없습니다.)
}
ptr-next = new_node;
}
}
void appending_node ( int age, int number)
{
Node *p;
p = make_node();
p-age = age;
p-number = number;
link_at_the_end_of_thelist( p);
}
void printlist(Node_h * L)
{
Node * ptr;
ptr = L-head;
while(ptr!=NULL)
{
printf(나이 : %d\n넘버 : %d\n, ptr-age, ptr-number);
ptr = ptr-next;
if(ptr!= NULL)
{
printf(,);
}
}
}
void main()
{
Node_h *c;
c = create();
appending_node(3, 11);
appending_node(2, 15);
appending_node(3, 20);
appending_node(5, 17);
appending_node(3, 30);
printlist(c);
}
책에는 appending_node랑 link_at_the_end_of_thelist 두 함수를 합쳐서 풀이해놨는데
저희 교수님은 저렇게 따로 함수를 짜셨더라고요. 그대로 해야할거 같아서 나눠서 하는데 저부분에서 자꾸 에러가 나는지 출력이 안되네요 ㅠ
그리고
typedef struct {
Node * head;
}Node_h;
이거 정확한 역활이 뭔가요?
typedef struct student
{
int age;
int number;
struct Node * next;
}Node;
이거랑 다른건 알겠는데 그냥 전역함수로 Node head; 하는것과 구지 저렇게 Node_h 구조체를 만들 필요성이 있나요?
전역하고 다시하려니까 머리 터질꺼 같네요 ㅠㅠ 꼭좀 알려주세요
| 번호 | 제 목 | 글쓴이 | 날짜 |
|---|---|---|---|
| 2752085 | 문자열을 랜덤하게 출력해서 대체,삽입,삭제 횟수를 각가 표시하고 그걸 표 형태로 출력 | 슬아s | 2026-10-20 |
| 2752056 | 포인터 && 배열 질문요~ (2) | 해찬나래 | 2026-10-20 |
| 2752031 | x^n 구하는 코드 짜봤는데 값이 틀려요 ㅠㅠ | 세실 | 2026-10-20 |
| 2752000 | 나 정말 미치겠어요..ㅠㅜ (4) | 다이 | 2026-10-20 |
| 2751978 | 문자열 질문이요.. | 초시계 | 2026-10-19 |
| 2751945 | 숫자 맞추는 프로그램이요 ㅠㅠ (1) | 동은 | 2026-10-19 |
| 2751917 | C언어 이중 연결 관련 질문합니다. | 유우 | 2026-10-19 |
| 2751888 | return의 정확한 의미좀 알려주세요 (3) | 올해1살 | 2026-10-19 |
| 2751857 | 포인터 배열 (2) | 터큰 | 2026-10-18 |
| 2751831 | 연산자? 질문입니다 (2) | 진주 | 2026-10-18 |
| 2751800 | C언어 기초질문입니다.. (3) | 핫블랙 | 2026-10-18 |
| 2751739 | 파일 출력을 구조체로 받을 때, 파일의 끝을 판별하는 방법을 알려주세요. (2) | 얼 | 2026-10-17 |
| 2751715 | unresolved external symbol 에러... | 이룩 | 2026-10-17 |
| 2751686 | 변수 설정에 관한 질문입니다. | 꽃달 | 2026-10-17 |
| 2751655 | 자료구조 연습문제 | 한무릎 | 2026-10-17 |
| 2751631 | gets 함수 질문이요. (4) | 해늘 | 2026-10-16 |
| 2751553 | 퀵정렬 소스인데 주석좀 달아주세요 (1) | 싴흐한세여니 | 2026-10-16 |
| 2751528 | 저기 이거하는법좀 질문.. (2) | 가람슬기 | 2026-10-15 |
| 2751445 | 도저히 풀 수가 없네요.... (2) | 신당 | 2026-10-15 |
| 2751412 | 어제부터 계속 해도.........안되는.... (1) | 족장 | 2026-10-14 |
