Thread: MS Visual C++ 6.0 bug?

  1. #1
    Registered User skillet's Avatar
    Join Date
    Feb 2002
    Posts
    20

    MS Visual C++ 6.0 bug?

    I am finding that adding or subtracting "one" to a pointer is actually adding the number of bytes that is allocated to the pointer type. To find the next value in memory, I thought I should add the number of bytes to the pointer:

    //should be next variable in memory?
    pointer = pointer + sizeof(pointer);

    but that was skipping over data. I found when I add "one":

    pointer++; //this works, but shouldn't?

    then I got the data I wanted (in this case, 8 bytes forward).

    This should display the memory address of one array element, and then you'll see that the next output is 8 bytes more.

    Maybe this is supposed to be the way it works, but I don't think so...

    Code:
    void main() 
    {
        double        m_dValue[10];
        double       *m_pValue;
        CString size;
    
        m_pValue = & m_dValue[0];
    
        //this shows address "6618360" on my PC
        size.Format("%d",m_pValue);
        AfxMessageBox(size);
    
        //this shows address "6618368" on my PC
        size.Format("%d",m_pValue+1);
        AfxMessageBox(size);
    }

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544

  3. #3
    Registered User skillet's Avatar
    Join Date
    Feb 2002
    Posts
    20
    ...beginning to see how that works. Thanks for the good "google" key

  4. #4
    C/C++Newbie Antigloss's Avatar
    Join Date
    May 2005
    Posts
    216
    check the faq to see why void main is wrong

  5. #5
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    If you are just learning C or C++ languages, VC++ 6.0 is NOT a good compiler to use because it does not support many of the current ISO standards -- it is a very very old compiler. A better compiler to use for learning is Dev-C++ which you can download free at www.bloodshet.net. But it too is not fully standard compliant.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  2. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 10:43 AM
  3. errors in my class....
    By o0obruceleeo0o in forum C++ Programming
    Replies: 9
    Last Post: 04-14-2003, 03:22 AM
  4. Visual Studio 6.0 Help
    By L_I_Programmer in forum C++ Programming
    Replies: 1
    Last Post: 03-24-2003, 10:35 PM
  5. why wont MS Visual C++ understand my #include <stdlib.h>
    By Master_Rondal in forum C Programming
    Replies: 5
    Last Post: 10-15-2002, 04:36 PM