왜 .. 같은 작업을 아래의 malloc없이 수행 할 수있을 때 내가 malloc을을 사용구조체와 함께 malloc을 사용하는 이유는 무엇입니까?
내가 메모리 위치를 초기화하지 않는 방법 N1 이해하기 힘든 시간을 보내고 있어요#include <stdio.h>
#include <conio.h>
struct node {
int data;
struct node *l;
struct node *r;
};
int main(){
//Case 1
struct node n1;
n1.data = 99;
printf("n1 data is %d\n", n1.data);
//Case 2
struct node *n2 = (struct node *) malloc (sizeof(struct node));
n2 -> data = 4444;
printf("n2 data is:%d\n",n2 -> data);
free(n2);
return (0);
}
- 데이터를 저장할 수 (99).
- 때 제 경우 경우 2.
당신은 내 전문가입니다! 정확한 답변을하고 내 마음 속에있는 모든 질문을 해결했습니다.내가 당신에게 1000 표를 줄 수 있으면 좋겠다. 하 .. 감사합니다. –
''4 바이트 포인터는 메모리에 복사하는 대신 레지스터에 전달할 수있는 것보다 훨씬 효율적입니다. –