C – String

Prev     Next C Strings are nothing but array of characters ended with null character (‘\0’). This null character indicates the end of the string. Strings are always enclosed by double quotes. Whereas, character is enclosed by single quotes in C. Example for C string: char string = {‘f’, ’r’, ‘e’, ‘s’, ‘h’, ‘2’, ‘r’, ‘e’, ‘f’, ’r’, ‘e’, ‘s’, ‘h’, ‘\0’}; (or) char string = “fresh2refresh”; (or) char string    = “fresh2refresh”; Difference between above declarations are, when we declare char as “string”, 20 bytes of memory space is allocated for holding the string value. When we declare char … Continue reading C – String