Skip to main content

Posts

Showing posts with the label Strings in C

Strings in C

Strings in C Strings are defined as an array of characters. The difference between a character array and a string is that the string is terminated with a special character ‘\0’. The string can be defined as the one-dimensional array of  characters terminated by a null ('\0’).  The character array or the string is used to manipulate text such as word or sentences.  Each character in the array occupies one byte of memory. The termination character ('\0') is important in a string since it is the only way to identify where the string ends Declaration of strings : Declaring a string is as simple as declaring a one dimensional array. Below is the basic syntax for declaring a string. char str_name[size]; In the above syntax str_name is any name given to the string variable and size is used define the length of the string, i.e the number of characters strings will store. Please keep in mind that there is an extra terminating character which is the Null character ('\0&