strcpy(...) works for c-strings only not for std::string. There is no need for strcpy(...) wiith std::string.
I don't know what you are trying to do on line 7. The std::string equivalent would look like:
string eName = s1 = emp_name;
By the way: system(...) does not return a string. So line 3 would lead to an invalid string.
Hi rsingh2083,
The prototype of strcat(),you see,it's char* strcat(char*,constchar*)
so strcat() can't work with two string object.if you want the variable "eName" to be a string object,the code should be like: string eName=s1+emp_name; //returns a string
I hope those can help you:)
if you want the variable "eName" to be a char* object,the code should be like:
char* eName=strcat(s1.c_str(),emp_name.c_str()); //returns a char pointer
NO.
You can't use .c_str() like this. 1) .c_str() returns a const char* not a char* and 2) you can't directly append to a std::string like this, bypassing all of the internal handling, checking, setting size etc etc etc. if you manage to get this to compile, it will blow up at run-time.