Question

This is a discussion on Question within the C Programming forums, part of the General Programming Boards category; Hello everybody, Can anybody explain to me what does the following example mean. Or any of you can show me ...

  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,807
    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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    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);
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

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, 12:47 AM

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