trouble in compiling this code

I have tried to compile this program from my C++ book. However, the compiler says that 'strcpy’ was not declared in this scope.

#include <iostream>
using namespace std;

int main() {
char Buffer[20] = {'\0'};
cout<<"enter a line of text"<<endl;
string LineEntered;
getline (cin, LineEntered);
if (LineEntered.length()<20){
strcpy (Buffer, LineEntered.c_str());
cout<<"Buffer contains: "<<Buffer<<endl;
}
return 0;
}
1
2
 
#include <cstring>  


PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.

Topic archived. No new replies allowed.