C Language | String Literals, Punctuators

String Literals /character array

A string literal is a sequence of characters enclosed within double quotes. The characters may be alphabets, digits, special characters and blank spaces.

“hello” “abc”  “a” “hello hi” “h2” “123”

What is the difference between ‘a’ and “a”?

‘a’ “a”
   
(i). character constant (i).String or character array

(ii).To store such a value the variable has to be declared as given below

Char n;

(ii). To store such a value the variable has to be declared as given below

char n[10];

(iii). For input we use “%c”

(iii). For input we use “%s”

(iv) size of ‘a’ is 1 byte

(iv) size of “a” is 2 bytes

Size of “HELLO” : 6

 

 

Punctuators / separators :

These are special symbols used in grouping and separating code. They define and shape function in a program. Punctuators are also known as separators.

Parentheses () Braces {} Brackets []
Semicolon ; Colon : Comma ,
Period .