【发布时间】:2015-10-03 18:27:25
【问题描述】:
#include <iostream>
#include <string>
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()); // This strcpy. is not declared in scope for some reason.
cout << "Buffer contains: " << Buffer << endl;
}
return 0;
}
这是错误:
main.cpp:14:43: error: 'strcpy' was not declared in this scope
为什么会出现这个错误?
【问题讨论】: