연결리스트 작성중 에러를 못잡겠습니다...
봄여울
질문 제목 :연결리스트 작성중 에러를 못잡겠습니다...현재 연결리스트로 특정 파일에서 불러와서 저장하는 프로그램을 제작중인데에러가 납니다... 도대체 어디부문이 문제인지 모르겠습니다..컴파일러 에러는 없구요 ... 포인터 오류인거 같은데.... 잘모르겠습니다.질문 내용 :연결리스트를 확실히 마스터한 상태가 아니라 많이 미흡한데 .그래도 한번 해보겠다고 인터넷에 올라와있는 소스 참조해서 열심히 만들었는데...컴파일러 오류는 없고 경고만 많네요... 하지만 막상 돌려보면 윈도우 에러 뜨고 꺼집니다 ㅠㅠ#includestdio.h
#includestring.h
#includememory.h
#includestdlib.h
typedef struct list{
char ip[1000];
int count;
struct list*next;
}node;void print_list(node*pwcounter); //연결리스트 출력
void scaninfo();
node*createnode();//새로운 노드를 연결리스트 뒤에 삽입. (중복x 데이터 삽입)
void filegets(file*fp);///전역 변수///
node*head=null; // 헤드 선언
int totalcount=0;
int nocount=0;
char buff[1000];
int main(){
node*starter=null; file*fp;
fp=fopen(c:\\access.log,r); while(fp!=null){
filegets(fp);
{ totalcount ++;} scaninfo();
createnode(); starter=head;// 중첩이 안된 ip총 횟수 구하는 곳
while(starter != null){ nocount++;
starter=starter-next; }
} starter=head; // 출력 부분
while(starter!= null){ print_list(starter);
starter= starter-next;
}
fclose(fp);
}
void filegets(file*fp){
char* tokken;
strtok(buff,:);
fgets(buff,sizeof(buff),fp);
}void scaninfo(){
node*scan=null;
node*last;
last=null; if(head == null){ head-next=createnode(); return;} scan=head; while(scan!=null){
if(strcmp(buff,(char*)scan-ip)==0)
{
++scan-count; return;
} last=scan;
scan=scan-next;
}
last-next=createnode();
}
node*createnode(){
node*newnode=null;
newnode=(node*)malloc(sizeof(node));
strcpy(newnode-ip,buff);
newnode-count= 1;
newnode-next=null; return newnode;}void print_list(node*pwcounter)
{ pwcounter=head;
printf(%s 는 %d회 기록됨, pwcounter-ip, pwcounter-count);
}
작성한 소스구요... 컨트롤 f10눌러서 하나씩 확인해본걸로는 크리에이트 노드 부분에서 next 링크해주다가 에러가 나는거 같습니다...근대 도무지 어떻게 잡아야 할지 모르겠습니다 도와주세요 ㅠㅠ