0

我正在尝试在 Visual C++ 6.0 中编译一些旧代码。缺少 DSW 文件,因此我将所有代码添加到新工作区中。

我有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");
   ...
}

还使用了其他功能,例如fopen_s, strncpy_s, strncat_sin a.cpp

并且b.h

#include <stdio.h>
#include <string.h>

char function_2(unsigned char * string2, int abc, int def)
{
   char buf2[200];
   sprintf_s(buf2, 200, "abcdef");
   strcat_s(buf2, 200, "ghijkl");
}

尽管已经有了stdio.hand 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.cppb.h

有没有我遗漏的设置?为什么我会收到这些错误?

4

1 回答 1

2

Visual Studio 2005 增加了 _s 版本功能。因此您需要使用更现代的 Visual Studio 版本。

于 2013-01-07T04:13:16.400 回答