Difference Between character and string in C.


Characters are simple alphabets such as a, b, c, d...., but with one exception. Any single-digit integer, such as 0, 1, 2, 3, 4,..., and special characters, such as $,%, +, -,*,..., etc., are similarly treated as characters in computer programming, and you can assign them to a character type variable by simply enclosing them in single quotes.

For example, we declare a character type variable ch and assign it the value 'a'.

char ch = 'a';

Strings are similar to sentences. They refer to a sequence of characters represented as a single data type. They're made up of a list of characters, which is actually an "array of characters." When passing information from the program to the user, strings come in quite handy.

Let’s see the following example to understand how to declare a string in C


/* String */
string str = "Ninjas";




Related Topics
Related Topics