Home > Software engineering >  Vc cstrings collection and string type conversion
Vc cstrings collection and string type conversion

Time:10-04

cstrings collection conversion

cstrings string
may want to add the relevant header files, CT2A it defined in the "atlconv. H"

Cstrings file1.
The string filename.
CT2A xx (file1);
Filename=xx;

turn cstrings char *

Cstrings strRootPath;
USES_CONVERSION;
Char * chRootPath=T2A (strRootPath);

turn cstrings int

Int MinSize=_ttoi (cstrings cst_MinSize);

turn cstrings float

Cstrings str_data;
Float f_data;
f_data=https://bbs.csdn.net/topics/_tstof (str_data);

/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */

string conversion collection

turn char * string
Char * p=(char *) (strpath. C_str ())

string turn float

String str_data="https://bbs.csdn.net/topics/12345";
Float f_data;
F_data=https://bbs.csdn.net/topics/atof (str_data c_str ());

string turn int
Int n=atoi (STR) c_str ());

CodePudding user response:

Thank you for your share

CodePudding user response:

String those things: BSTR - LPSTR - LPWSTR - cstrings - VARIANT - COleVariant - _variant_t CComBSTR - _bstr_t
http://blog.csdn.net/pizi0475/archive/2010/03/04/5346708.aspx

CodePudding user response:

If I remember correctly, T2A seems to have a length limit, 1024, had better turn WCHAR * char * or use WideCharToMultiByte () function

CodePudding user response:

reference VisualEleven reply: 3/f
if I remember correctly, T2A seems to have a length limit, 1024, had better turn WCHAR * char * or use WideCharToMultiByte () function

The include \ atlconv. H:
# define W2A (LPW) (\
((_lpw=LPW)==NULL)? NULL: (\
(_convert=(lstrlenW (_lpw) + 1), \
(_convert & gt; INT_MAX/2)? NULL: \
ATLW2AHELPER ((LPSTR) alloca (_convert * sizeof (WCHAR)), _lpw, _convert * sizeof (WCHAR), _acp))))
.
# define T2A W2A
.
To sum up, the length of the T2A restricted by alloca can allocate the maximum number of bytes:

/STACK (STACK Allocations)
Home | the Overview | How Do I | would Options

The Stack Allocations (/Stack: reserve [, commit]) option sets The size of The Stack in bytes.

To find this option in the development environment, click Settings on the Project menu, Then click the Link TAB, and click the Output in the Category box. The Reserve text box (or in the Reserve argument on the command line) specifies the total stack allocation in virtual memory. The default stack size is 1 MB. The would rounds up The specified value to on 4 bytes.

The optional value specified in The Commit text box (or in The Commit argument on The command line) is subject to interpretation by The operating system. In Windows NT, it specifies The amount of physical memory to The allocate at a time. The Committed virtual memory causes space to be reserved in The paging file. A who Commit The value saves time when The application needs more stack space, but - The memory requirements and possibly The startup time.

Specify the reserve and commit values in decimal or C - language notation.

Another way to set the size of the stack is have the STACKSIZE statement in a module - definition. (DEF) file. STACKSIZE overrides the stack Allocations (/stack) option if both are specified. You can change the stack after the. EXE file is built by using the EDITBIN tool.


CodePudding user response:

66666666666666

CodePudding user response:

I am such conversion between cstrings and string:

From cstrings to string, if is the UNICODE project:
 cstrings strSource; 
CStringA strTmp;
STD: : string target;
StrTmp=strSource;
Target=strTmp. Get string ();

If non UNICODE project, directly below target=strSource. Get string ();

From the string to the cstrings are simple
 STD: : string SRC. 
Cstrings target;
Target=SRC. C_str ();


CodePudding user response:

Before 66666, with VC, the type conversion is really a headache,

CodePudding user response:

T2A such transformations sent us a memory leak, don't use this to turn in circulation, and under the unicode and multiple character sets, transformation way is different also

CodePudding user response:

CodePudding user response:

Thanks for sharing!!!!!!!!!!

CodePudding user response:

MARK...

CodePudding user response:

nullnull
  • Related