Home > Software engineering >  MFC string concatenation of the code? Please god help me to check it out!
MFC string concatenation of the code? Please god help me to check it out!

Time:09-25


LPCTSTR SpecFileName=: : sysInI currPath + "\ \ L1000A ini";

: : sysInI currPath returns the type string, the string together after SpecFileName appeared a lot of man gibberish,
After a breakpoint tracking: : sysInI currPath variable the value returned to normal, excuse me what is going on?

Character set used in the configuration properties for the whole project is to use a multibyte character set (didn't use the unicode character set),

CodePudding user response:

Type string into LPCSTR needs to call c_str () member function

CodePudding user response:

reference 1st floor paschen response:
type string into LPCSTR needs to call c_str () member function


But there was no c_str cstrings type string () member function,

In addition, if under the Unicode character set, LPCTSTR SpecFileName=: : sysInI. CurrPath + "\ \ L1000A ini"; Showed normal, not gibberish, but if change character set that will be too much in the changes and do more harm than good,

CodePudding user response:

: : sysInI currPath + "\ \ L1000A ini"; Returns a temporary variables, finished destroyed!
Pointer to a string and LPCTSTR

Try using the following statement:
Cstrings SpecFileName=: : sysInI currPath + "\ \ L1000A ini";

CodePudding user response:

The
reference 3 floor jianwen0529 response:
: : sysInI. CurrPath + "\ \ L1000A ini"; Returns a temporary variables, finished destroyed!
Pointer to a string and LPCTSTR

Try using the following statement:
Cstrings SpecFileName=: : sysInI currPath + "\ \ L1000A ini";


Get SpecFileName there will still be garbled, continue to execute, SpecFileName variable only keep \ L1000A ini the string, and: : sysInI. CurrPath character of path with \ L1000A ini together!

CodePudding user response:

refer to the second floor zhang2006407022 response:
Quote: refer to 1st floor paschen response:
type string into LPCSTR needs to call c_str () member function
but there was no c_str cstrings type string () member function to add, if under the Unicode character set, LPCTSTR SpecFileName=: : sysInI. CurrPath + "\ \ L1000A ini"; Showed normal, not gibberish, but if change character set that will be too much in the changes and do more harm than good,


: under the multi-byte LPCTSTR SpecFileName=(CStringA) : : sysInI. CurrPath + "\ \ L1000A ini";

CodePudding user response:

LPCTSTR SpecFileName=: : sysInI currPath + L "\ \ L1000A ini";

CodePudding user response:

A pointer to a string based does not support + operation

CodePudding user response:

You have Chinese characters in the string object??

CodePudding user response:

 LPCTSTR SpecFileName=: : sysInI currPath + TEXT (" \ \ L1000A ini "); 
  • Related