char buff[100]="note";
char* pstr="book";
char* p;
strcat(buff, pstr);
puts(buff);
strncat(buff, "12345",3);
puts(buff);
strcat(p,buff);        //오류: 쓰레기 주소에 값을 넣으려고 시도

strcat(pstr, buff);    //오류: 상수값에 값을 집어넣으려고 시도


alloca => stack 세그먼트 영역에 동적메모리 할당

장점: 함수 호출, 반환시 스택 영역을 사용하는데 스택영역에 동적메모리를 할당하면 함수 반환시 메모리가 자동 해제되기때문에 

free할 필요없음

+ Recent posts