2.1 The Character Segment

Wonder where all these strings are created? I bet you do. Well, when you define a string, memory is allocated in the Character Segment. When you define another one, space is allocated after the first string. That means that if you go beyond the boundaries of the first string, you'll end up in the space allocated to the second string.

After the second string there is a void. If you end up there your program will end with an error-message. And what about the space before the first string? Well, take a look at this diagram:

Character Segment

The lower memory is at the bottom. Yes, before your strings there are two other areas, the TIB and the PAD. We'll elaborate on that in the next section.

The Character Segment is created at run-time. That means that it isn't there when you compile a program. The compiler just keeps track of how much memory would be needed to create such a Character Segment and stores that information in the header.

When you run the program the header is read first. Then the Character Segment is created, so it is already there when your program starts executing. When you exit the program, the Character Segment is destroyed and all information stored there is lost (unless you save it first).