Thread: Memory location dangerously close...

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

    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
    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
    859
    no "&"'s.
    Yoshi

  5. #5
    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
    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, 02: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