문자열 상수 이래도 되는겁니까? ㅋ
나슬
질문 제목 : 문자열 상수 이래도 되는겁니까? ㅋconst char*로 정의된 식별자에 전달된 문자열... 그해당주소에 있는 문자열이 변할수 없는 거고.
포인터의 주소는 바뀔수 있는거네요;; 포인터의 주소가 변할수 없게 하려면 어떻게 해야할까요 하하 const (char*) 요래 해야하나요..질문 내용 :
#include stdio.h?xml:namespace prefix = o ns = urn:schemas-microsoft-com:office:office /?xml:namespace prefix = o /?xml:namespace prefix = o /?xml:namespace prefix = o /
const char* str = this is program;
main()
{
char* is = what is program;
puts(str);
str = is;
puts(str);
}
해결봤어요..
#include stdio.h?xml:namespace prefix = o ns = urn:schemas-microsoft-com:office:office /
const char* str = this is program;
const (char*) stri = hi my name is ...;
main()
{
char* is = what is program;
puts(str);
//*str = this is progran;
stri = is;
str = is;
puts(str);
}
-
이리온
질문자가 알아서 답변달고 갈게여;;
str이 가리키는 주소는 변경할수있으나 처음저장된 위치의 문자열은 변경할수 없다.
stri가 가리키는 주소는 변경할수 없으니 처음 저장된 우치의 문자열은 변경할수 있다.
() 괄호 연산자가 *연산자보다 우선순위가 높다. 컴파일할때 괄호연산이 되는걸보면 스택을 이용하는 듯? -
볼1매그녀
const char * const str = \...\;