strcpy_s does not return properly, and further code is not executed


This Content is from Stack Overflow. Question asked by Adrian

Can someone explain why this only prints out Hello World1, and then hangs for 1 sec before coming back to the command prompt, without printing anything else?

#include <iostream>
#include <cstddef>

using namespace std;
int main()
    char    tchar[4];
    cout << "Hello World1n";
    strcpy_s(tchar, sizeof(tchar), "Dick");
    cout << "Hello World2n";
    cout << tchar << "n";
    cout << "Hello World3n";


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?