#include <string.h>

sdi12CRC::sdi12CRC()
  {
    CRC = 0;
    responseToDCommandWithoutCRC = new char[MAX_D_COMMAND_RESPONSE_SIZE];
    responseToDCommandWithCRC = new char[MAX_D_COMMAND_RESPONSE_SIZE];
    asciiCRC = new char[ASCII_CRC_SIZE];
    strcpy(responseToDCommandWithoutCRC,"");
    strcpy(responseToDCommandWithCRC,"");
    strcpy(asciiCRC,"");
  }

上面是我不久前用 Borland C++ builder 编写和测试的 C++ 程序的代码片段。有用。我现在正在学习 Visual Studio 2010,所以我想我可以利用我过去的工作来帮助了解 Visual Studio。

我在上面的代码中收到警告和错误,但上面的代码是合法的 C++ 代码。我在 VS 文档中找不到任何帮助来了解我做错了什么以及如何修复它。(我并不是说它不在文档中;只是说我找不到它)。

Warning 1   warning C4627: '#include <stdlib.h>': skipped when looking for precompiled header use

Error   4   error C3861: 'strcpy': identifier not found

这里给出了什么?string.h 不是 strcpy 所需的标头吗?因此 strcpy() 应该可以编译。我不明白或不知道的是什么?

任何帮助将不胜感激。

有帮助吗?

解决方案

问题是您将项目配置为使用预编译标头,但您不使用它们。只需调整项目设置以不使用预编译标头。

其他提示

尝试显式添加两者 #include <stdlib.h> 然后 #include <string.h>

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top