Unix to Windows Porting Dictionary for HPC |
|
|
RSS
LinksFunction List
|
Table of Contents This function gets the standard host name for the local computer, and stores it in the name parameter. Since this function has a one-to-one correspondence with the same function in Windows, there should not be any other changes required other than including the needed header file. However, note that this function is a C++ function limited to Windows 2000 Professional, Windows 2000 Server, or above.
#include <Winsock2.h>
char* buffer[256];
if (gethostname(buffer, 256) == 0)
printf("The local host name is %s.", buffer);
else
printf("gethostname error.");
|
|
|
|