writing to one array overwrites another

Discussion in 'C++' started by headedtomexico, Sep 11, 2010.

  1. headedtomexico

    headedtomexico New Member

    Joined:
    Sep 11, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I have a simple class
    class Info {
    public:
    long One[31];
    long Two[79];
    };

    i'm reading values from a couple char arrays, when I write to Two[0], it overwrites One[31].


    CurInfo->One[31] = atol(BufferOne);
    chatoutf("%d",CurInfo->One[31]);
    CurInfo->Two[0] = atol(BufferTwo);
    chatoutf("%d",CurInfo->One[31]);
    if I feed bufferone a -1, and then buffertwo a 623, I get the following output in my chat window:

    Quote:
    -1
    623
    I have searched and searched, and this is just frankly blowing my mind... I'm assuming One[31] is the 4 bytes immediately before Two[0]... but I dont understand why its putting the "623" into the wrong place in memory... anyone know whats going on?

    I would post all the code, but its several thousand lines
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice