Note that there are some explanatory texts on larger screens.

plurals
  1. POHow are variables of various data types stored in C++(native) binary?
    primarykey
    data
    text
    <p>I started my adventure with C++ one week back. I have read a lot about C++. I was experimenting with the following:</p> <pre><code> char * String1 = "abcdefgh"; </code></pre> <p>I, then, tried to modify its value in the following way:</p> <pre><code> String1[2] = 'f'; </code></pre> <p>This resulted in an UNHANDLED EXCEPTION. But the following results in proper execution:</p> <pre><code> char String2[9]="abcdefgh"; String2[7]='s'; </code></pre> <p>I tried to extract information about the binary generated using above code using DUMPBIN. DUMPBIN is a Visual Studio Tool. I used the /ALL option to extract every information contained in the binary.</p> <p>I could see two instances of <strong>"abcdefgh"</strong> in the RAWDATA section. And I understand why.</p> <p>My questions are as follows:</p> <p>1) Although both String1 and String2 are essentially pointers to two different instances of the same character sequence, why is the String1 manipulation not a legal one?</p> <p>2) I know the compiler generates a SYMBOL TABLE for mapping variable names and their values. IS there any tool to visualize the SYMBOL TABLE in Windows OS?</p> <p>3) If I have an array of integers instead of the character sequence, can it be found in the RAWDATA?</p> <p>I could also see the following in RAWDATA:</p> <pre><code>Unknown Runtime Check Error......... Stack memory around _alloca was corrupted....... ....A local variable was used before it was initialized......... ....Stack memory was corrupted.. ........A cast to a smaller data type has caused a loss of data. If this was intentional, you should mask the source of the cast with the appropriate bitmask. </code></pre> <p>How do these things get into the binary executable? What is the purpose of having these messages in the binary(which obviously is not readable)?</p> <p>EDIT: My question 1) has a word INSTANCES, which is used to mean the following:</p> <p>The character sequence "abcdefgh" is derived from a set of non-capitalized ENGLISH ALPHABETS, i.e., {a,b,...,y,z}. This sequence is INSTANCIATED twice and stored at two memory locations, say A and B. String1, points to A(assumption) and String2 points to B. There is no conceptual mix-up in the question. </p> <p>What I wanted to comprehend was the difference in the attributes of the memory locations A and B, i.e., why one of them was immutable.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload