C – String Constant

Home/C - Tutorial/C - Constants/C – String Constant
C – String Constant 2017-06-12T08:53:53+00:00

String constants

A string constant consists of zero or more character enclosed in quotation marks. Several string constants are given below.

“Welcome to C Programming”                      “ ”

“a+b\n”                                                          “Error\a\a\a”

There is a difference between the constant ‘A’ and “A” in C, the first ‘A’ is a character constant while the second “A” is string constant. The notation ‘A’ is a constant occupying a single byte containing the ASCII code of the character A. The notation  “A”  on the other hand ,is a constant that occupies two bytes one for ASCII code of A and another for the null character with the value 0,that terminates all the string.

Example :

 

 

Output :

Value of a = Welcome to C Programming

Prev Next