오류 좀 잡아주세요..
앵겨쭈
질문 제목 : 질문 내용 :
#include stdio.h
#include stdlib.h
#include string.h
#define true 1
#define false 0
typedef struct listnodetype
{
int data;
struct listnodetype* link;
}listnode;
typedef struct linkedlisttype
{
int elementcount;//현재원소개수
listnode headernode;//헤더노드
}linkedlist;
void display(linkedlist* link);
int getlenreturn(linkedlist* link);
listnode* getelementreturn(linkedlist* link,int position);
linkedlist* creaditlinkedlist(linkedlist* link);
int addelementcount(linkedlist* link,int position,listnode temp);
int main()
{
linkedlist* link=null;
listnode data;
link=creaditlinkedlist(link);
if(link != null)
{
data.data=1;
addelementcount(link,0,data);
data.data=3;
addelementcount(link,0,data);
data.data=5;
addelementcount(link,0,data);
display(link);
}
else{
puts(메모리 오류입니다!);
return;
}
puts(감사합니다^^\n);
return 0;
}
linkedlist* creaditlinkedlist(linkedlist* link)
{
link=(linkedlist*)malloc(sizeof(linkedlist));
if(link != null){
memset(link,0,sizeof(linkedlist));
}
else{
puts(헤더노드 메모리 할당 실패!);
return null;
}
return link;
}
void display(linkedlist* link)
{
int i=0,arrlen;
printf(현재 원소 개수: %d\n, link-elementcount);
arrlen=getlenreturn(link);
for(i=0; iarrlen; i++){
printf([%d]: %d\n,i,getelementreturn(link,i)-data);
}
}
int getlenreturn(linkedlist* link)
{
int count=0;
if(link != null){
count=link-elementcount;
}
return count;
}
listnode* getelementreturn(linkedlist* link,int position)
{
int i;
listnode* node=null;
listnode* temp=null;
if(link != null){
if(position = 0 &&
position link-elementcount){
node=&(link-headernode);
for(i=0; iposition; i++)
{
node=node-link;
}
temp=node;
}else{
puts(메모리 오류!);
}
}
return temp;
}아무리 눈이 뚫어져라 찾아보아도 어디가 오류인지 알수가 없네요..
구조체 선언 오류도 나고 함수 인자 오류 나는데
구조체 선언 제대로 했고, 함수 인자도 틀린게 없는데
뭐가 계속 오류라는건지...
잡아주시면 감사하겠어요.
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2700562 | 함수포인터에서요 (7) | 소심한여자 | 2025-07-06 |
2700530 | 전처리문 질문입니다. (1) | 아놀드 | 2025-07-05 |
2700510 | c언어를 어케하면 잘할수 있을까요.. | 연연두 | 2025-07-05 |
2700484 | 두 개가 차이가 뭔지 알려주세요...(소수 찾는 프로그램) (2) | 날위해 | 2025-07-05 |
2700426 | 인터넷 창 띄우는 질문이요 (1) | 정훈 | 2025-07-04 |
2700400 | 원넓이를 계산이요 ㅜㅜ | 천칭자리 | 2025-07-04 |
2700368 | if에 관해서 질문이요... | Orange | 2025-07-04 |
2700339 | 이거 결과값이 왜이런건지.. (4) | 그댸와나 | 2025-07-04 |
2700313 | 파일 읽어서 저장하는데 빈파일일 경우 문재가 발생하네요.. (2) | 크나 | 2025-07-03 |
2700287 | 구조체 동적할당 연습을 하는데 오류가 뜹니다...(해결) (3) | 아련나래 | 2025-07-03 |
2700264 | 문자와 숫자 동시에 입력??? | 글고운 | 2025-07-03 |
2700236 | txt파일로만 쓰고 읽게 하려면 어떻게 해야 하나요..?? (8) | 미국녀 | 2025-07-03 |
2700211 | 전위 연산자 (2) | 어른처럼 | 2025-07-02 |
2700183 | C에서 파일이름을 받고, 그 파일의 사이즈를 출력해줘야하는데 내용이 출력이 안되네요 ;ㅅ; | 피스케스 | 2025-07-02 |
2700150 | 꼭좀 도와주세요ㅠㅠㅠ | 호습다 | 2025-07-02 |
2700095 | 연산문제...질문... | 오빤테앵겨 | 2025-07-01 |
2700070 | while문 , 3의배수 출력하는 프로그램좀 짜주세욤. | 횃불 | 2025-07-01 |
2700041 | 초보인데요 ㅎ 배열안에 배열을 집어넣을수 있나요?? | 헛장사 | 2025-07-01 |
2700012 | 배열// (1) | 전갈자리 | 2025-07-01 |
2699895 | 무한루프에 빠집니다.!! 해결좀부탁드려요 (10) | 선아 | 2025-06-30 |