2012-05-19 67 views
0
#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。在Visual Studio 2010中使用strcpy()我不明白什麼?

我得到了一個警告,並在上面的代碼錯誤,但上述代碼是合法的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()應該編譯。我不明白或瞭解的是什麼?

任何幫助將不勝感激。

回答

3

問題是您將項目配置爲使用預編譯頭文件,但您沒有使用它們。只需調整您的項目設置,以不使用預編譯頭。

+0

問題解決了。謝謝。 –

1

嘗試明確將兩個#include <stdlib.h>然後#include <string.h>

+0

感謝您的評論! –

相關問題