[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] Mere om netværksprogrammering...?



On Sun, 9 Jan 2000, Henrik Brix Andersen wrote:

> 	printf("Update server IP: %s\n", inet_ntoa(update_server_ent->h_addr));
> 
> Skulle den sidste linie ikke printe IP# fra update_server_ent? Problemet
> er,
> at koden ikke skriver det rigtige IP#. 

Du skal bruge -Wall -W som parametre til gcc -- så vil du få at vide at
inet_ntoa ikke tager den type parameter som du forsøger at give den.
inet_ntoa tager en struct in_addr -- du overfører den en char* (som
tilfældigvis peger på så struct in_addr).

inet_ntoa(*(struct in_addr*) update_server_ent->h_addr)


cast char* til en struct in_addr*
dereferer struct in_addr* så hele strukturen overføres til funktionen som
den vil have det.



-- 
==============================================================================
Erwin Andreasen   Herlev, Denmark <sslug@sslug>          UNIX System Programmer
<URL:http://www.andreasen.org>              <*>         (not speaking for) DDE
==============================================================================



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *