구조제 동적메모리 할당

asleea의 이미지

#include<stdio.h>
#include<stdlib.h>
 
typedef struct _Node
{
	unsigned int number;
	struct _Node* prev;
	struct _Node* next;
}Node;
 
Node* head = (Node*)malloc(sizeof(Node));
Node* tail;
 
int main()
{
 
	return 0;	
}

malloc 부분에서 이니셜라이저가 상수가 아닙니다. 라는 에러가 뜨는데 머가 문제인가요 .?;;;

croae의 이미지

malloc 할당은 int main() 함수 안에서 실행되어야 합니다.

chadr의 이미지

c에서 함수 호출은 반드시 함수 안에서 수행 되어야합니다.

-------------------------------------------------------------------------------
It's better to appear stupid and ask question than to be silent and remain stupid.