VS2017环境下使用strcat函数问题

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    char c[50] = { "People's Republic of'\0'" };
    char str[] = { "China" };
    printf("%s\n", strcat_s(c, str));
    system("pause");
    return 0;
}

图片说明

使用strcat函数是连接两个字符组。
那么运行结果应该是:People's Republic of China
为何出现的黑框是如图结果???
求大佬解答QAQ

正确代码

#include "pch.h"
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    char c[50] = { "People's Republic of " };
    char str[] = { "China" };
    strcat_s(c, str);
    printf("%s\n", c);
    system("pause");

    return 0;
}

运行结果

图片说明

错误总结

1、对于char c[50] = { "People's Republic of'\0'" };,字符串c并不需要写出'\0',因为系统编译时运行默认自动在字符串结尾处添加'\0';
2、strcat_s(c, str)默认返回类型是errno_t,你输出strcat_s(c, str)相对于输出errno_t类型的结果,由此出现上述错误结果;
3、未正确理解strcat_s(c, str)功能。其真正功能是将str连接到c的结尾处,故其结果是在c字符串中,而不是在返回值中。

菜单栏点 项目 属性 C/C++ ,然后把SDL检查设置成否 ,接下来把strcat_s改成strcat

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^