【问题标题】:What don't I understand about using strcpy() in Visual Studio 2010?我对在 Visual Studio 2010 中使用 strcpy() 有什么不明白的地方?
【发布时间】:2012-05-19 18:43:05
【问题描述】:
#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() 应该编译。什么是我不了解或不知道的?

任何帮助将不胜感激。

【问题讨论】:

    标签: c++ visual-studio-2010 strcpy


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      尝试显式添加#include &lt;stdlib.h&gt; 然后#include &lt;string.h&gt;

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-03-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-05-12
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多