회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
채점 현황
게시판
그룹
더 보기
재채점 기록
블로그
도움말
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
c언어로 liked list queue를 만들었는데 에러가 나네요....
sa090180
3년 전
0
nullptr로 예외가 생긴다는 에러가 자구 뜨는데 왜이러는지 잘 모르겠아요 ㅜㅜ
#include <stdio.h> #include <stdlib.h> typedef struct Node { int data; struct Node* next; }Node; typedef struct queue { Node* front; Node* rear; int size; }queue; void push(queue* q, int item) // rear의 뒤로 node를 추가시켜 주는 함수 { Node* temp = (Node*)malloc(sizeof(Node*)); temp->data = item; temp->next = NULL; if (q->rear == q->front) { q->rear = temp; q->front = temp; } else { temp->next = q->rear; q->rear = temp; } return; } int pop(queue* q) { if (q->front==NULL && q->rear==NULL) { printf("queue is empty!\n"); return; } else { int item; Node* temp = (Node*)malloc(sizeof(Node*)); temp = q->front; item = q->front->data; q->front = q->front->next; free(temp); return(item); } } void print(queue* q) { Node* temp = (Node*)malloc(sizeof(Node*)); printf("<queue>"); for (temp = q->front;temp != NULL;temp = temp->next) { print("%d ", temp->data); } printf("\n"); return; } void main(void) { queue* q = NULL; q->front = NULL; q->rear = NULL; push(q, 3); push(q, 2); print(q); pop(q); print(q); }
댓글을 작성하려면
로그인
해야 합니다.
sa090180 3년 전
nullptr로 예외가 생긴다는 에러가 자구 뜨는데 왜이러는지 잘 모르겠아요 ㅜㅜ