Character conversion function and digital conversion function _c language in C language standard library

Source: Internet
Author: User
Tags lowercase uppercase letter

Convert character to number:

#include <stdlib.h>

Atoi (); Converts a character to an integer example: Char ch1;int i=atoi (CH1);

ATOL () converts a character to a long integer example: 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-precision type example: String str1;double d=strtod (STR1);

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

Strtoul (); Converts a string into a no-length integer example: Sting str3; unsinged long int uli=str (STR3);

Convert numbers to characters:

Itoa (); Converts an integer to a character
Example: int i; Char ch1; Itoa (I,ch1,radix);
Radix is base: Want to convert ch1 to decimal is 10, octal is 8, hexadecimal is 16

Ltoa (); Converts a long integer to a character example: Long int i li; Char CH2; Ltoa (Li,ch2,radix);

Ultoa (); Converts a no-length 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);//Get Lower=c

ToUpper (); Converts one by one lowercase letters to uppercase letters
Example: Char lower=c; Char Upper=toupper (lower);//Get Upper=c

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.