Home > Back-end >  About the strcat (STR1, STR2);
About the strcat (STR1, STR2);

Time:10-02

Void CTCPDlg: : OnButton2 ()
{the using namespace STD.
Char MY [100]={0};
Cstrings str1;
Cstrings str2;
String STR3="";
GetDlgItem (IDC_EDIT1) - & gt; GetWindowText (str1);
GetDlgItem (IDC_EDIT2) - & gt; GetWindowText (str2);
Strings STR1=(LPTSTR) (LPCTSTR STR1);
STR2 string STR2=(LPTSTR) (LPCTSTR);//converting cstrings string
strcat (STR1, STR2);


}
What's the problem,,,
Why
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- the Configuration: TCP server program - Win32 Debug -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Compiling...
TCP server program Dlg. CPP
C: \ Users \ \ Administrator \ Desktop, xin, TCP server program, the TCP server program Dlg. CPP (274) : error C2664: 'strcat' : always convert parameter 1 from 'class STD: : basic_string & lt; Char, struct STD: : char_traits & lt; char> Class, STD: : allocator 'to' char * '
No user - defined - conversion operator available that can perform this conversion, or the operator always be called
An error occurred when executing cl. Exe.

TCP server program Dlg. Obj - 1 error (s), and 0 warning (s)
,,,,,,,,,,

CodePudding user response:

What do you want to achieve? Strcat parameter is chart *, you have to plug in a string variable, of course want to report a type error,

CodePudding user response:

Prototype: extern char * strcat (char * dest, char * SRC); , the function returns a pointer, two parameter is a pointer, the memory of the first parameter points to address must be able to accommodate the size of the connection of two strings, return a pointer to the dest,
Strcat (STR1, STR2); Into strcat (STR1 c_str (); , STR2. C_str ());
  • Related