C characters and strings

Source: Internet
Author: User


Character and string

A character is a letter, number, punctuation, or other such symbol; a string is a sequence of any character.
Strings are used to store text data consisting of letters, numbers, punctuation marks, and other symbols.


The C language uses the char data type to store old characters. Char is an integer value type.
C-language character storage: in computer memory, all data is stored in numeric mode.
Characters cannot be stored directly, but each character has a corresponding numerical encoding.
This encoding is called an ASCII code or an ASCII character set.
In this encoding, each uppercase/lowercase letter, number, punctuation, and other symbols correspond to a 0 ~ 255 value.





# Include

 
  
Void main () {char a1 = 'a'; char a2 = 90; // Note: to print a string, use % cprintf ("\ n to print a = % c ", a1); // Note: To print ASCII, use % dprintf ("\ n to print the ASCII code of a: % d", a1 ); printf ("\ n print a2: % c", a2); printf ("\ n print a2's ASCII: % d", a2 );}

 


Running result:




# Include

 
  
Void main () {// print 26 English characters printf ("26 English case:"); for (int I = 65; I <= 122; I ++) {printf ("\ n % c", I);} system ("pause ");}

 



Running result:





Related Article

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.