Home > Article > Backend Development > The difference between s and c in c language
The difference between string constant (s) and character constant (c) is: 1. s uses double quotes to represent a string, while c uses single quotes to represent a single character; 2. s is stored in read-only memory , and c is stored in read-write memory; 3. s can be compared, but c can only be compared with other c.
The difference between s and c in C language
In C language, s
and c
represents string constants and character constants respectively.
Character constant (c)
String constant (s)
Other differences
##Example
<code class="c">int main() { char c = 'a'; // 字符常量,表示字符 'a' char str[] = "Hello world"; // 字符串常量,表示字符串 "Hello world" printf("字符常量:%c\n", c); printf("字符串常量:%s\n", str); return 0; }</code>
The above is the detailed content of The difference between s and c in c language. For more information, please follow other related articles on the PHP Chinese website!