#include <stdio.h>
const char *typestr(int type)
{
if (type == 1)
return "type_1";
else
return "type_2";
}
void main()
{
char *temp;
temp = (char *) typestr(1);
temp[1] = 'A';
printf("%s\n", temp);
getchar();
}
이렇게 만들었는데 Windows에서는 type_1이 출력되네요. ㄷㄷㄷ
DEBUG모드로 컴파일하면 runtime memory에러가 나구요.
DEBUG모드하고 RELEASE모드하고 왜 다르게 해 놓았는지 모르겠네요
페이지 테이블에 read_only로 하면 메모리 exception이 나는데, 이걸
그냥 넘어가게 하려면 ring3 stack을 찾아가서 고치는 개삽질을 해야하는데...
적어도 visual studio 8에서는 스트링 상수를 스택에 만드는 삽질은 하지
않습니다.