Program Memory Issue
<p>Can I always assume that if...</p>

<pre><code>int main()
{
    ...
    foo1();
    foo2();
    foo3();
    ...
    return 0;
}
</code></pre>

<p>that foo1() will always precede foo2() and foo2() will always precede foo3() in program completion (referring to highest abstraction of completion)?</p>

<p>In my actual program, whether foo2() and foo3() happen depend on whether foo1 is a very "long" function, meaning if there is a giant for loop in foo1(), then by the time I finish and get to the end of the program, foo2(), and foo3() don't happen.  In my program foo1()-foo3() access the same map.  f001() initializes all usable elements in the map and foo2(),foo3() then replace initializations with aliasing data read from files. Any reason why this is happening?</p>

<p>Here are the 2 functions, the rest of the program is sortof large and off topic:</p>

<pre><code>void loadDEADBEEF()
{
    for (long long i=0; i&lt;=268435888; i+=4)//268435888
    {
            MainMemory[i] = 3735928559;
            HEXMainMemory[i] = "DEADBEEF";
    }
}

void LoadMemory(string str)//load hex dump into memory
{
    filecounter++;
    vector&lt;int&gt; V;//temperary vector
    vector&lt;string&gt; tempV;//temperary vector
    ifstream inClientFile( str.c_str(),ios::in ); //stream object
    vector&lt;string&gt; words;
    string word;
    int offset=0;
    if ( !inClientFile ) cerr &lt;&lt; "File couldn't be opened" &lt;&lt; endl;//test if instruction file can be opened
    //fill string vector with all file values and determines length of program
    while (inClientFile &gt;&gt; word)words.push_back(word);//capture raw code from file
    const int wordCount=words.size();//determine most efficient sizing for vectors
    tempV.reserve(wordCount);//size vector
    for(int i=0; i&lt;wordCount; i++)
    {
        if (i==0 &amp;&amp; words[i].length()==10) tempV.push_back(words[i]);//include first word to obtain data offset (memory insertion point)
        if (words[i].length()==8 
                &amp;&amp; words[i].find(".")==string::npos )

            tempV.push_back(words[i]);//cut out undesired strings from vector
    }
    for( int y=2; y&lt;10; y++) offset+=hexCharValue(tempV[0][y])&lt;&lt;(4*(9-y));//convert offset from hex to decimal
    tempV.erase(tempV.begin());//delete offset from vector
    V.resize(tempV.size());//resize vector
    for( int j=0; j&lt;tempV.size(); j++ )//convert string hex to numerical decimal
    {

        for( int y=0; y&lt;8; y++) V[j]+=hexCharValue(tempV[j][y])&lt;&lt;(4*(7-y));//4194608+4*
        if (load_memory) 
        {
            MainMemory.insert(mapType::value_type(4*j+offset,V[j]));//insert (location in memory,data)
            HEXMainMemory.insert(pair&lt;int, string&gt;(4*j+offset,tempV[j]));
        }    
    }
    if( filecounter == 1 ) PC_start = offset-4;
}
</code></pre>

<p>So, the first function is "foo1()" and the second is "foo2()".  Here is main:</p>

<pre><code>#include 
...
typedef map&lt;int, int&gt; mapType;//format of map: ( address, data )
typedef map&lt;int, string&gt; mapType2;//format of map: ( address, data )
mapType MainMemory;
mapType2 HEXMainMemory;
...
int main(int argc, char **argv)
{
    ...
    loadDEADBEEF();
    LoadMemory("hello_1.txt");//reginfo
    ...
    return 0;
}
</code></pre>
