Data types in 2_c languages (v) Char

Source: Internet
Author: User

1.1 Char Type 1.1.1 Char constant, variable

char c; Define a char variable

' A ', constant of Char

The essence of char is an integer, an integer with a size of only 1 bytes

1.1.2 printf Output Char

%c means to output a character instead of an integer

1.1.3 non-printable char escape character

\a, Alarm.

\b Backspace

\ nthe line break

\ r Enter

\ t tab

\ \ Slash

\ ' Single quotation mark

\ "Double quotation marks

\? Question mark

1.1.4 Char and unsigned char

Char values range from 128 to 127

unsigned char is 0-255

#include <stdio.h>intMain01 () {CharC//define a variable of type charc ='a'; printf ("%c\n", c); //C = 4;//c equals an integer 4//C = ' 4 ';//c equals one character 4c ='D'; C= C + +;//An algorithm for converting uppercase letters to lowercase lettersprintf ("%c\n", c);//52 is the ASCII code of the ' 4 ' characterC='9'; //C = c-48;c = C-'0';//An algorithm for converting characters to integersprintf"%d\n", c); return 0;}intMain () {Charc ='\a'; C='a'; printf ("%c", c); C='\b'; printf ("%c", c); C='b'; printf ("%c", c); C='\ n'; printf ("%c", c); C='a'; printf ("%c", c); C='b'; printf ("%c", c); C='\ r'; printf ("%c", c); C='C'; printf ("%c", c); //c = ' \ R '; //printf ("%c", c);printf ("\ n"); C='a'; printf ("%c", c); C='\ t'; printf ("%c", c); C='b'; printf ("%c", c); C='\ ''; printf ("%c", c); CharA =0;//to define a signed charUnsignedCharb =0;//to define an unsigned charB = B-1; A=127; A= A +5; printf ("%d", a); return 0;}

Source: Intelligence Podcast for study only

Data types in 2_c languages (v) Char

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.