struct example *e
이있는 경우 function(&e)
과 function(e)
의 차이점은 무엇입니까?구조체 예제 * e : 함수 (& e)와 함수 (e)의 차이
예.
이 첫 번째 코드이다
#include <stdio.h>
struct example
{
int x;
int y;
};
void function (struct example **);
int main()
{
struct example *e;
function (&e);
return 0;
}
void function (struct example **e)
{
/* ... */
}
는 그리고이 두 번째 코드는 다음 두 코드 사이의 차이가 무엇
#include <stdio.h>
struct example
{
int x;
int y;
};
void function (struct example *);
int main()
{
struct example *e;
function (e);
return 0;
}
void function (struct example *e)
{
/* ... */
}
? 감사합니다.
두 번째 경우에 'e = malloc (2 * sizeof (struct example))'을 함수에 넣을 수 있습니까? –
@user 당신은 할 수 있지만, 함수에서'e' 만 로컬로 변경할 것입니다. 함수 매개 변수'e'는 값에 의해 전달됩니다. –
좋아, 첫 번째 경우에는'* e = malloc (2 * sizeof (struct example))'을 실행하면'main()'에서도 변경됩니다. 맞습니까? –