#include <stdio.h>

struct TEST
{
 int m_idata;
};

int main(void)
{
 TEST *test = new TEST [5];
 printf(\"default===================\\n\");
 for(int i =0 ; i < 5 ; i++)
 {
  test[i].m_idata = i;
  printf(\"%d\\n\",test[i].m_idata);
 }
 printf(\"=========================\\n\");

 TEST *temp;

 temp = &test[2];
 test[2] = test[3];
 test[3] = *temp;


 printf(\"after===================\\n\");
 for(int i =0 ; i < 5 ; i++)
 {
  printf(\"%d\\n\",test[i].m_idata);
 }
 printf(\"=========================\\n\");

 return 0;
}


원하는건 0 1 2 3 4 가
0 1 3 2 4 가 되게하고싶은데요

여기서 3과 2를 구조체 맴버를 복사해서 바꾸는게아니라
메모리가 할당되어있는 주소를 바꿔주고싶어요 ㅜ

오류나는이유는
temp가 test[2] 의 주소를 가지고있다가
test[2] 가 가르키는 메모리위치를 test[3] 으로바꿔서
temp 도 test[3] 의 위치를 가르키는것같은데요

별짓을 다해봐도 저이상이 안되네요

어찌해야할까요 ㅜㅜ