A man of Love and Hate char (character type)

Source: Internet
Author: User

Today to summarize the char type, the usual writing algorithm for this thing feel a bit around, in the final analysis or this part of the knowledge is not familiar with so a little afraid of him, but do not be afraid, today to summarize

First, when it comes to character data types, char type, well, it's a data type.

Then, it's the character variable .

The emphasis of a character variable is to store a character in a character variable, not the shape of the character, but the ASCII code of the character.

Input: GetChar ();

Output: Putchar ();

The difference between GetChar and scanf is that he can enter spaces

Character-type constants:

1. General

A

2. Escaping

1. ' \ t '

Slash + character

2. ' \ ' + character Anscii code,

\DDD octal corresponding characters

String constants:

"ABDF"

The difference between ' a ' and ' a '

Note:: There are no string variables, only string constants exist

Storing a string requires a character array

Character array:

Char A[5]

1. Initialization of character arrays

1. Class with character constants

Char a[8]={' C ', ' h ', ' I ', ' n ', ' a '}

If not initialized, the values of the elements of the array are random

2. If partially initialized, the following automatic null character

2. Class with a string constant.

Char a[8]={"China"};

Char a[8]= "China";

' !!!! The assignment operation must never use a string constant, but can be used to assign a value to a character constant

Char a[100];

A[100]= "ABC" is wrong.

2.

A man of Love and Hate char (character type)

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.