Defining String Variables:



Just like of integers or any other data type, the string variables which are basically array of characters can be defined using the following syntax,
            char string_variable[size];

The string_variable is actually the name of the array and size represents the maximum number of characters that can be stored and it must be a positive integer value.

For example, Consider the statement,


The above statement defines an array and reserves 30 bytes for storing characters. Since the last byte is used for storing null character ‘\0’ so total number of characters specified by user cannot exceed 29.



Previous                                                                                    Next


Powered by Blogger.