Checking to which address pointer points

This is a discussion on Checking to which address pointer points within the C Programming forums, part of the General Programming Boards category; Hello, is it possible to check the address a pointer points to? I am writing a program where a user ...

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    23

    Checking to which address pointer points

    Hello,

    is it possible to check the address a pointer points to? I am writing a program where a user can enter an address in hex format and I have multiple pointers in my program pointing to different addresses. Now I want to check if one of them points to the address provided by the user. Is this possible? If so, how?

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Sure, you can simpy use the == operator...
    Code:
    int z;
    int *A;
    int *B;
     
    A = &z
    B = &z
    
    if (A == B)
      puts("I nearly plotzed!");

  3. #3
    Registered User
    Join Date
    Nov 2010
    Location
    xian china
    Posts
    31
    yes, you can compare them directly

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling GNU MP
    By mattnp12 in forum C Programming
    Replies: 3
    Last Post: 06-23-2011, 03:58 PM
  2. Yahtzee C++ programme help
    By kenneth_888 in forum C++ Programming
    Replies: 13
    Last Post: 09-05-2007, 02:14 PM
  3. Problems about gcc installation
    By kevin_cat in forum Linux Programming
    Replies: 4
    Last Post: 08-09-2005, 09:05 AM
  4. Another Linked List plee
    By Dragoncaster131 in forum C Programming
    Replies: 3
    Last Post: 05-15-2004, 05:40 PM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM

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