2014-04-19 1 views
0

를 재 할당하기위한 구조체 변수를 지우기 :은 내가 정의한 구조체의 유형을 반환하는 기능이

typedef struct irPulseSet 
{ 
    int pulseCount; 
    int (*pulses)[2]; 
} irPulseSet; 

irPulseSet irReadPulse() 
{ 
    irPulseSet outputPulseSet; 
    //some stuff 
    return outputPulseSet; 
} 

하지만 루프의 내부를 호출하고 있습니다 :

while(1) 
{ 
    irPulseSet currentlPulseSet = irReadPulse(); 
    //some other stuff here 
} 

내가 알고 싶은 것은 currentPulseSet의 설정을 해제하는 것이므로 while 루프의 다음 반복에서 다시 설정할 수 있습니다.

답변

1

변수 currentlPulseSet이 스택에 있습니다. 범위를 벗어나면 자동으로 메모리에서 제거됩니다. 아무 것도 할 필요가 없습니다.

+0

그래서 각 루프 반복 끝에 스택이 꺼지십니까? – user2166351

+0

예, while() 또는 do-while() 표현식에서 사용하려고하면 어떻게됩니까? – this

관련 문제