다음 C언어 프로그램이 실행되었을 때의 결과는?
#include <stdio.h>
#include <string.h>
int main(void) {
char str[50] = "nation";
char *p2 = "alter";
strcat(str, p2);
printf("%s", str);
return 0;
}정답 2번
strcat(str, p2)는 첫 번째 문자열 str의 끝에 p2가 가리키는 문자열을 이어 붙입니다. ‘nation’ 뒤에 ‘alter’가 붙으므로 str은 ‘nationalter’가 되고 ②가 출력됩니다.
콘텐츠 정보
- 자료 유형
- 편집복원
- 검수 상태
- 내용 검수 완료
- 해설 작성·검수
- 정처LAB 편집 기준
- 최종 검수
- 2026-08-21