Memory location dangerously close...

This is a discussion on Memory location dangerously close... within the C++ Programming forums, part of the General Programming Boards category; char* filename; // memory location: 0065FA98 char* outfile; // memory location: 0065FA94 when changed, the other "overlaps" each other's input. ...

  1. #1
    A Banana Yoshi's Avatar
    Join Date
    Oct 2001
    Posts
    857

    Memory location dangerously close...

    char* filename; // memory location: 0065FA98
    char* outfile; // memory location: 0065FA94

    when changed, the other "overlaps" each other's input. help?
    Yoshi

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Not necessarily. Can I see the context in which you are using this? For now I what you are saying isn't true. But maybe your code needs a little fixing.

  3. #3
    moi
    moi is offline
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946

    Re: Memory location dangerously close...

    Originally posted by Wraith_Master
    char* filename; // memory location: 0065FA98
    char* outfile; // memory location: 0065FA94

    when changed, the other "overlaps" each other's input. help?
    now, is 0065FA98 the value of filename or &filename?
    hello, internet!

  4. #4
    A Banana Yoshi's Avatar
    Join Date
    Oct 2001
    Posts
    857
    no "&"'s.
    Yoshi

  5. #5
    moi
    moi is offline
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    are you sure? where are you getting these numbers from?
    hello, internet!

  6. #6
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I'm guessing wraith_master is doing one of the following:

    Code:
    std::cout << (void *)filename << std::endl;
    //or
    printf("%p", filename);
    Either way that sounds correct to me. A pointer is only four bytes. So being 4 bytes appart in memory isn't so strange to me. A pointer points to memory, not to a block of memory the way an array does. I just don't see the problem here.

  7. #7
    moi
    moi is offline
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    Originally posted by master5001
    I'm guessing wraith_master is doing one of the following:

    Code:
    std::cout << (void *)filename << std::endl;
    //or
    printf("%p", filename);
    Either way that sounds correct to me. A pointer is only four bytes. So being 4 bytes appart in memory isn't so strange to me. A pointer points to memory, not to a block of memory the way an array does. I just don't see the problem here.
    exactly what i was thinking. if he is printing them that way, then it is &filename who'se value is 65FA98. and since that's the address of the pointer var itself, all is fine as you described.
    hello, internet!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory usage and memory leaks
    By vsanandan in forum C Programming
    Replies: 1
    Last Post: 05-03-2008, 05:45 AM
  2. Assignment Operator, Memory and Scope
    By SevenThunders in forum C++ Programming
    Replies: 47
    Last Post: 03-31-2008, 06:22 AM
  3. Shared Memory - shmget questions
    By hendler in forum C Programming
    Replies: 1
    Last Post: 11-29-2005, 01:15 AM
  4. Ghost in the CD Drive
    By Natase in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 10-12-2001, 05:38 PM
  5. accessing Memory location
    By a_learner in forum C Programming
    Replies: 6
    Last Post: 10-10-2001, 02:16 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21