I searched with my problem but no success
I do not know how the proper function is implemented Well I have a file library file in which I store the variable and the function There is another file called I do not really know how to fix my problem. I got the error Maybe I have declared strong logic with that star signs and empires Can anyone help me? Very little support to reduce the code: The normal code that works fine (without functon) is in main.c: I have such a question, so I edit here. How do I implement it in the function? IFhost () .
iphost () .
main.c where I play the function
iphost (...) .
adr_srvr not the element
sin_addr .
/ home / user / desktop / pap_lab2 / 2 /biblioteka.h|23 Terror: request for member ???? Sin_addrâ ???? Some do not have structure or association.
main.c
iphost (argv [2], and adr_srvr); // Fine ?
I can not go to adr_srvr.sin_addr.
char * arg is the argument to input by me, 4 example: "127.0.0.1".
adr_srvr.sin_addr This store is 127.0.0.1
srvr_addr char *
< / P>
int main (int argc, char * argv []) {int z; Int x; Char * srvr_addr; Struct sockaddr_in adr_srvr; Struct sockaddr_in adr; Host Host * He; Int len_inet; Ints; Four Degrams [512]; Struct in_addr ** addr_list; Four buff [512]; // USTV ENE POLSENIA // CGE YPISANO IP if (RGR [1] [0]> gt (=) '0' and ampv; [1] [0] & lt; = (four) '9') {printf (" Paradeopodobany Viprovodozono IP:% s \ n ", RGR [1]); Inet_aton (argv [1], and adr_srvr.sin_addr); Srvr_addr = inet_ntoa (adr_srvr.sin_addr); } And {} ...}
---------
else {if (get = gethostbyname (arg)) == NULL) // // Get host information header ("gethostbyname"); Return 2; } // Print information about this host: printf ("wiki HOST: '% s'", arg); Printf ("IP:"); Addr_list = (Straight in_ADD **) that-> H_ADR_list; Printf ("% s", srvr_addr = inet_ntoa (* addr_list [0])); Printf ("\ n"); }
adr_srvr is an indicator to access your fields For, you need to use
adr_srvr.sin_addr instead of
adr_srvr-> sin_addr . In general, use
a. Field when
a is a straight, and
a-> field when
a is an indicator for a structure.
Comments
Post a Comment