#include <stdio.h>
#include <stdlib.h>
typedef struct _test
{
int x;
struct _test* y;
} test;
test** global;
numGlobal = 0;
void function1(..., , , test** global)
{
global = (test**)malloc(sizeof(test*)*5);
for (...)
{
test* temp = (test*)malloc(sizeof(test));
temp->x = ...
temp->y = ....
if ( ... )
{
*(global+numGlobal) = temp;
printf("global[0].x : %dn", global[0]->x); // ¿äºÎºÐ (1)
numGlobal++;
}
}
return;
}
int main() {
function1();
printf("global[0].x : %dn", global[0]->x); //¿äºÎºÐ (2)
return 1;
}
Äڵ带 ´ëÃæ ¿ä¾àÇÑ °Ì´Ï´Ù. À§¿¡¼, (1) °ú (2)´Â ¶È°°Àº Äڵ带 º¹ºÙÇÑ °Çµ¥, (1)Àº Àß ÀÛµ¿ÇÏ°í (2)´Â ¼¼±×¸àÆ® ¿¡·¯¸¦ ÁÝ´Ï´Ù. ¿Ö ÀÌ·²±î¿ä?
Áú¹® | 1261¸íÀÌ Àоú¾î¿ä. 18.118.218.133