Results 1 to 2 of 2

Thread: syntax of (struct sockaddr_in *)p->ai_addr

  1. #1
    Join Date
    Dec 2010
    Posts
    23
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default syntax of (struct sockaddr_in *)p->ai_addr

    I'm doing some network programming but I am having trouble understanding exactly what the syntax of this line means. It is:

    (struct sockaddr_in *)p->ai_addr

    I understand the p->ai_addr points to the element of ai_addr in the object pointed to by p, but I don't understand the beginning part (struct sockaddr_in *) and how that is being applied to the p->ai_addr part.

    Thanks in advance.

  2. #2
    Join Date
    Feb 2011
    Posts
    8
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: syntax of (struct sockaddr_in *)p->ai_addr

    That's C code. It is a simple cast, telling the compiler that p->ai_addr is a sockadder_in* rather than whatever type the member actually is (likely a void*).

Similar Threads

  1. QList<struct>
    By Axsis in forum Newbie
    Replies: 11
    Last Post: 12th October 2015, 07:48
  2. Struct into a C++ class
    By franco.amato in forum General Programming
    Replies: 24
    Last Post: 30th September 2010, 16:13
  3. I can not found the gl_FragColor struct.
    By Treehouse in forum Qt Programming
    Replies: 0
    Last Post: 7th January 2010, 14:14
  4. Struct in network
    By sribalaji in forum Qt Programming
    Replies: 7
    Last Post: 26th March 2008, 10:38
  5. struct problem...
    By hiuao in forum General Programming
    Replies: 3
    Last Post: 5th April 2007, 07:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.