Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to convert integer type to character type?
How to convert integer type to character type?

For numeric conversion only, forced type conversion is enough, cChar = (char)iInt; However, it should be noted that converting an integer to a character type will cause the loss of extra bits.

Itoa()

or sprintf()

can be used to convert a numerical value or integer into char*.

The usage of sprintf is similar to that of printf. Only the first parameter needs to be set as a variable.

int a = 100;

char* szText = new char[10];

sprintf(szText, "%d", a);

p>

Extended information:

Usually the entire string is used as the operation object, such as: finding a substring in the string, obtaining a substring, inserting a substring at a certain position in the string string and delete a substring, etc. The necessary and sufficient conditions for two strings to be equal are: the lengths are equal, and the characters at each corresponding position are equal. Assume that p and q are two strings. The operation of finding the position where q first appears in p is called pattern matching. The two most basic storage methods of strings are sequential storage and linked storage.

Baidu Encyclopedia-String