String 在visualc+中用*编译代码+;6 我试图在Visual C++ 6中编译一些旧代码。DSW文件丢失,因此我将所有代码添加到新的工作区中

String 在visualc+中用*编译代码+;6 我试图在Visual C++ 6中编译一些旧代码。DSW文件丢失,因此我将所有代码添加到新的工作区中,string,visual-c++,stdio,String,Visual C++,Stdio,我有如下a.cpp #include "vld.h" #include "afx.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <iostream> #include "b.h" ... void function_1(char* string1) { char buf[2000]; strcpy_s(&buf[0], 2000,

我有如下
a.cpp

#include "vld.h"
#include "afx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include "b.h"

...

void function_1(char* string1)
{
   char buf[2000];
   strcpy_s(&buf[0], 2000, string1);
   strcat_s(&buf[0], 2000, "_append");
   ...
}
尽管已经有了
stdio.h
string.h
,但我仍然得到了错误

'sprintf_s': undeclared identifier
'strcat_s': undeclared identifier
'strcpy_s': undeclared identifier
'fopen_s': undeclared identifier
'strncpy_s': undeclared identifier
'strncat_s': undeclared identifier
对于
a.cpp
b.h


是否有我遗漏的任何设置?为什么会出现这些错误?

Visual Studio 2005中添加了版本函数。因此,您需要使用更现代的Visual Studio版本。

而不是直接传递
200
2000
,您应该传递
sizeof buf
sizeof buf2
。这意味着,如果更改数组的大小,所有字符串函数将自动在新大小上运行。这仅在
buf
buf2
为数组类型时有效。例如,如果它们被声明为
char*
,这将不起作用。
'sprintf_s': undeclared identifier
'strcat_s': undeclared identifier
'strcpy_s': undeclared identifier
'fopen_s': undeclared identifier
'strncpy_s': undeclared identifier
'strncat_s': undeclared identifier