Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What are the uses of character constants and string constants? The difference?
What are the uses of character constants and string constants? The difference?
Character constants are characters enclosed in a pair of single quotation marks. Such as' a',' 9','!' . Generally, it operates as integer data.

A string constant is a sequence of 0 or more characters enclosed in double quotation marks (""), which is usually used to store output strings.

The differences between character constants and string constants are: different characters, different storage and different operations.

First, different personalities.

1. character constant: the character constant contains only one ASCII character, and the length of the constant is 1.

2. String constant: A string constant can have several ASCII characters, and the length of the constant is greater than or equal to 0.

Second, the storage is different.

1. Character constant: The character constant only takes up one byte in the memory.

2. String constant: How many bytes (at least one character terminator) does a string constant occupy in the storage? Depending on the length of the constant.

Third, the operation is different.

1. Character constant: a character constant is equivalent to an integer value and can participate in expression operation.

2. String constant: String constant represents an address value (the location where the string is stored in memory) and cannot participate in expression operation.