C language standard library character conversion function and number conversion function

  • 2020-04-02 02:17:49
  • OfStack

Convert characters to Numbers:

# include < Stdlib. H >

The atoi (); Converts a character to an integer     Example: char ch1; Int I = atoi (ch1);

Atol (); Converts a character to a long integer   Example: the char ch2; Long l = atol (ch2);

Atof (); Converts a character to a floating point   Example: char ch3; Float f = atof (ch3);

Strtod (); Converts a string to a double type   Example: string str1; Double d = strtod (str1);

Strtol ();   Convert a string to a long integer: string str2; Long int li = strtol (str2);

Strtoul (); String to unsigned long integer example: string str3; Unsinged long int uli = STR (str3);

Conversion of Numbers to characters:

Itoa ();   Converts an integer to a character
Example: int I; Char ch1; Itoa (I, ch1, radix);  
Radix: converts ch1 to 10 in decimal, 8 in octal, and 16 in hexadecimal

Ltoa ();   Convert a long integer to a character example: long int I li; Char ch2; Ltoa (li, ch2, radix);

Ultoa ();   Converts an unsigned long integer to a character   Example: unsiged long int uli; Char ch3; Ultoa (uli, ch3, radix);

Conversion of characters and characters:

# include < Ctype. H >

Tolower (); Converts an uppercase letter to a lowercase letter
Example: char upper = C; Char lower = tolower (upper); / / the lower = c

The toupper ();   Convert a lowercase letter to an uppercase letter
Example: the char   The lower = c; Char upper = toupper (lower); / / upper = C


Related articles: