문제
다음 C언어 프로그램이 실행되었을 때의 결과는?
① nation ② nationalter ③ alter ④ alternation
정답
2번
해설
정답: 2. strcat은 str 뒤에 p2를 이어 붙이므로 "nation" + "alter" = "nationalter"가 되어 ②가 정답이다.
오답 풀이
- 1번: nation은 결합 전 문자열이다.
- 2번: nationalter가 strcat 결과로 정답이다.
- 3번: alter는 p2만의 값이다.
- 4번: alternation은 잘못된 결합 결과이다.
보충 개념 strcat(dest, src)은 dest 끝에 src를 이어 붙인다.