Tokens in C++: Strings

 


WHAT ARE STRINGS?

        Strings are a special type of character array, where all the data is stored in a continuous memory locations. At this stage of discussions, we will introduce the the concepts of strings, but in later discussion, we will present a much more elaborate concept of strings. Strings can be demonstrated as an array of characters, as seen in the diagram below:

        
        In this scenario, we can clearly see that when the word "Hello!" is added to the program is added, an array of 7 bits, each able to hold a character, is created. When strings are allocated, these contiguous memory spaces are filled with data. Finally, an additional memory space is kept to add a null character to signify the end of a string. 

        Strings are characterized be characters which are encapsulated inside double quotes (""). This is the limit to which we will understand for strings at this stage. In later discussions about data-types, we will have an extensive discussion about strings as a data-type, and how data is added, extracted and modified in strings.


 

Comments