Thread: Question

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    7

    Question

    Hello everybody,

    Can anybody explain to me what does the following example mean. Or any of you can show me the reference to explain it?

    #define MESSAGE(MID,Respn) (MID = *((unsigned int *)Respn))

    Thanx.

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    That would take two variables and cast respn to an unsigned int pointer and assign the value stored at that address to MID.

    Code:
    unsigned int x = 10;
    unsigned int y = 0;
    
    MESSAGE(x, &y);
    
    printf("%u", x);
    Not a great example but it should work.
    Woop?

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by prog-bman View Post
    That would take two variables and cast respn to an unsigned int pointer and assign the value stored at that address to MID.

    Code:
    unsigned int x = 10;
    unsigned int y = 0;
    
    MESSAGE(x, &y);
    
    printf("%u", x);
    Not a great example but it should work.
    actually more interesting example would be
    Code:
    unsigned int x;
    float y = 2.34;
    
    MESSAGE(x, &y);
    
    printf("%u", x);
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM