String Constants in C Programming

String Constants

A string constant consists of zero or more characters 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 a string constant. The notation 'A' represents 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 the ASCII code of A and another for the null character with the value 0, which terminates the string.

Example:



Other basic types of constants in C are:

Ready to get started?

Ready to embark on your journey into the world of C programming? Our comprehensive course provides the perfect starting point for learners of all levels. With engaging lessons, hands-on exercises, and expert guidance, you'll gain the skills and confidence needed to excel in this fundamental programming language. Let's dive in and unlock the endless possibilities of C programming together!