-
카테고리
-
세부 분야
프로그래밍 언어
-
해결 여부
미해결
[12:34] 질문 있습니다.
20.09.19 20:52 작성 조회수 174
0
strcat_s를 연습하던 도중에 C6386 error 가 발생해서 질문드립니다. 구글링해도 무슨 말인지 이해가 안갑니다...ㅠ strcat_s에서 size를 11로 수정했을 때는 에러가 발생하지 않지만 값이 출력되지 않습니다...
또 Release일 때랑 Debug일 때랑 결과가 다른데 그 이유도 같이 궁금합니다.
<code>
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char source[] = "Copy this!";
char dest[] = "do it again!";
strcat_s(source, 50, dest);
cout << source << endl;
cout << dest << endl;
return 0;
}
이 때 strcat_s line에 밑줄 쳐지면서 C6386 error 라고 뜹니다.
<Debug일 때 결과>
Copy this!do it again!
do it again!
C:\Users\wawoo\source\repos\Inflearn 강의용 6\Debug\Chapter6_6.exe (process 12792) exited with code -1073740791.
Press any key to close this window . . .
runtime error 뜨면서 값은 제대로 출력이 됩니다.
<Release일 때의 결과>
Copy this!do it again!
it again!
C:\Users\wawoo\source\repos\Inflearn 강의용 6\Release\Chapter6_6.exe (process 3516) exited with code 0.
Press any key to close this window . . .
앞에 do 가 생략돼서 나옵니다...
감사합니다!
답변을 작성해보세요.
0
Hello Yeo
2020.09.20
안녕하세요?
https://en.cppreference.com/w/c/string/byte/strcat
strcat_s의 사용법을 다시 확인해보시고
크기가 11인 배열에 이어서 데이터를 쓰면 무슨 일이 일어날까? 를 고민해보셨으면 좋겠네요.
답변 1