vs2022字符串函数报错

img


问一下这种情况为什么会报错啊,在vs2022里面使用的,在书上看到的代码和这个差不多

strcat_s有三个参数,你只输入两个,所以报错。

errno_t strcat_s(char *Destination, size_t SizeInBytes ,const char *Source);
//Destnation 被添加字符串
//SizeInBytes 字节(注:内容大小不能超过这个数)
//Sourse添加的字符串

#include<stdio.h>
#include <string.h>
#include <iostream>
int main()
{ 
    char put1[100] = "fuc";
    char put2[100] = "nij";
    strcat_s(/*_Destination:*/put1,put2);  //_Destination:编码进去的时候发现没定义,因为注销掉!下面也是一样!
    printf("%s",put2);
    printf("%s",put1);
    system("pause");
    return 0;
}

结果:

img

VS2022的代码开头加上
#define _CRT_SECURE_NO_WARNINGS
关闭不安全提示,这样可以直接使用不带_s的函数。