You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lee Sun-Hyoup edited this page Feb 17, 2014
·
1 revision
문자열 상수는 다음 data변수와 같은 것을 말한다.
#include<stdio.h>intmain()
{
char* data = "Hello, World!";
return0;
}
문자열 상수는 메모리 영역 중 코드영역에 들어가기 때문에 data의 메모리를 수정하게 될 경우 코드 영역을 변조 할 수 있다.
그렇기 때문에 문자열 상수를 가르키는 포인터를 사용하게 될 경우 strcpy를 이용하여 힙 영역 혹은 스택 영역에 존재하는 변수에 복사하여 사용하자.