Hi,
I want to get the hostname and the ip address of the machine in C on both windows and linux environments. Are there any functions in C which will give me this information?
Thanks,
Chandana.
Hi,
I want to get the hostname and the ip address of the machine in C on both windows and linux environments. Are there any functions in C which will give me this information?
Thanks,
Chandana.
Last edited by Chandana; 08-17-2009 at 07:54 AM.
gethostname(), gethostbyaddr(), gethostbyname().
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
Thanks for the reply.
Can you give me some sample code which uses this gethostname(). I am trying to call gethostname() from the main function, but I am getting "segmentation fault" error.
Post your code that is giving you the seg fault.
bit∙hub [bit-huhb] n. A source and destination for information.