C String Variable Type


[rps-include post=6557]

String is multiple characters added together. “Hi Poftut” is a string. Actually C do not direct String type but character type is used to store single and multiple characters.

Character

Character types is defined with char keyword. Single character will hold 1 byte in the memory. Character type normally hold ASCII characters but third party libraries provides support for different character types like UTF-8, UTF-16 etc.

char mychar=’a’;

String

As stated above string is a list of character types. We can define string like below.

char name[6]={'i','s','m','a','i','l'};

Previous definition will create an char array which is equal to string. Above definition may seem a little bit error prone. We can define string more practical and less error prone like below.

char name[]="ismail";

[rps-include post=6557]

LEARN MORE  strcmp() C Library Function Usage with Examples

Leave a Comment