Integer Conversion to string: char * itoa (int value, char * string, int radix );
Convert decimals to strings: sprintf (string, format control column, data );
Decimal number of a string: double atof (const char * nptr );
String to integer: int atoi (const char * nptr );
Test code:
Copy codeThe Code is as follows: # include <stdio. h>
# Include <stdlib. h>
Int main ()
{
Int a = 2013420;
Float B = 2.054f;
Double c = 5.24;
Char sa [20], sb [20], SC [20];
// Convert integer a to a string
Itoa (a, sa, 10 );
Puts (sa );
// Convert floating point data to a string
Sprintf (sb, "% g", B );
Puts (sb );
// Convert double data to a string
Sprintf (SC, "% lg", c );
Puts (SC );
Printf ("========= below is the string conversion to numerical ===========\ n ");
Char * s1 = "123", * s2 = "1.23 ";
Printf ("% d \ n", atoi (s1 ));
Printf ("% g \ n", atof (s2 ));
Getchar ();
Return 0;
}