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

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.

Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680
Mike Jablonski
  • 1,703
  • 6
  • 27
  • 41

2 Answers2

3

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.

K-ballo
  • 80,396
  • 20
  • 159
  • 169
1

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

paulsm4
  • 114,292
  • 17
  • 138
  • 190