need your help

This is a discussion on need your help within the C Programming forums, part of the General Programming Boards category; im trying to figure out what this means. its problably not compliated at all but my c programming is a ...

  1. #1
    nas
    nas is offline
    Registered User
    Join Date
    Jun 2002
    Posts
    14

    need your help

    im trying to figure out what this means. its problably not compliated at all but my c programming is a little rusty.

    bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr));

    ok i get lost at the (srtruct sockaddr *)&my_addr
    whats that * doing is it pointing to something. just explain that one bit of code to me. thanks.
    peace out

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    It's a type cast. The line:

    (srtruct sockaddr *)&my_addr

    states:

    "The address of variable 'my_addr', is a pointer of type 'struct sockaddr'."

    If you aren't sure what a type cast is, it's when you tell one variable type that it's actually another one.

    I believe here, your sturcture is 'struct sockaddr_in' or something similar, and you're telling the function that it is just a 'sockaddr' structure.

    Quzah.
    Last edited by quzah; 07-22-2002 at 11:15 PM.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

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