Question

#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,"");
  }

Above is a code fragment from a C++ program that I wrote and tested some time ago with Borland C++ builder. It works. I'm now learning Visual Studio 2010, so I thought I use my past work to help learn about Visual Studio.

I get an a warning and and an error on the above code, yet the above code is legit C++ code. I can't find any help in the VS documentation to learn what I'm doing wrong and how to fix it. (I'm not saying it's not in the documentation; just saying I can't find it).

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

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

What gives here? Isn't string.h the required header for strcpy? Thus strcpy() should compile. What is it that I don't understand or know about?

Any help will be most appreciated.

Was it helpful?

Solution

The problem is that you configured the project to use precompiled headers, but you are not using them. Just adjust your project settings to not use precompiled headers.

OTHER TIPS

Try explicitly adding both #include <stdlib.h> then #include <string.h>

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top