Cstring to int conversion (UNICODE environment)
Cstring strip;
Strip = _ T ("34 if 12 is hit ");
Int I = _ ttoi (strip );
Convert cstring type to int type
The simplest way to convert data of the cstring type to an integer type is to use a standard string to an Integer Conversion routine.
Although you usually suspect that using the _ atoi () function is a good choice, it is rarely the right choice. If you want to use Unicode
Character, you should use _ ttoi (), which is compiled into _ atoi () in the ANSI coding system, while in Unicode
In the encoding system, compile it into _ wtoi (). You can also consider using _ tcstoul () or _ tcstol (), which can convert strings into any hexadecimal long integers (such as binary, eight
Hexadecimal, decimal, or hexadecimal), the difference is that the converted data is unsigned, while the latter is opposite. See the following example:
Cstring hex = _ T ("fab ");
Cstring decimal = _ T ("4011 ");
Assert (_ tcstoul (Hex, 0, 16) = _ ttoi (decimal ));
Only Unicode is supported in EVC, so the method is as follows:
Cstring to int:
Cstring strmytry = _ T ("123 ");
Int imytry =-1;
Swscanf (strmytry, _ T ("% d"), & imytry );
Int to cstring:
Int imytry =-1;
Cstring strmytry = _ T ("");
Strmytry. Format (_ T ("% d"), imytry );