Home >Backend Development >C#.Net Tutorial >Usage of single quotes and double quotes in c language
Abstract: Single quotes and double quotes in C language are used to define string constants. Single quotes define a character array with a limited length, which is stored in the data area and can be modified; double quotes define a character array stored in the code area. String constant, unlimited length, cannot be modified, and can contain escape characters.
Usage of single quotes and double quotes in C language
Get straight to the point:
Single quotes (') and double quotes (") are used to define string constants in C language, but each has different usage and meaning.
Detailed expansion:
Single quotation marks (')
Define string constants, which are stored in the code area of the program.
Single quotes:
<code class="c">char str1[] = 'Hello'; // 定义一个长度为 6 的字符数组</code>
<code class="c">char* str2 = "Hello World!"; // 定义一个指向字符串常量的指针</code>
It should be noted that in C language, string constants are immutable and their contents cannot be changed once defined.
The above is the detailed content of Usage of single quotes and double quotes in c language. For more information, please follow other related articles on the PHP Chinese website!