I used the strcpy() function and it only works if I use C-string arrays like:
char a[6] = "text";
char b[6] = "image";
strcpy(a,b);
but whenever I use
string a = "text";
string b = "image";
strcpy(a,b);
I get this error:
functions.cpp: no matching function for call to
strcpy(std::string&, std::string&)
How to copy 2 strings of string data type in C++?
You shouldn’t use
strcpy()to copy astd::string, only use it for C-Style strings.If you want to copy
atobthen just use the=operator.