找不到sethostname标识符错误。 [英] sethostname identifier not found error.
本文介绍了找不到sethostname标识符错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想设置本地主机的名称。我正在使用sethostname()函数,但是我收到如下错误:
错误C3861:''sethostname'':找不到标识符。
下面是代码片段:
WSADATA wsa;
/// Initialise winsock ///
if (WSAStartup(MAKEWORD( 2 , 2 ),& wsa )!= 0 )
{
// 套接字初始化失败///
退出(EXIT_FAILURE);
}
char setname [ 128 ] = Ayesha-PC;
sethostname(setname, sizeof (setname));
解决方案
< blockquote>您是否正在寻找 SetComputerNameEx [ ^ ]?
根据 winsock文档 [ ^ ]没有这样的功能。
你可能已经在基于Unix的应用程序中看到了这个例子。函数sethostname存在,(虽然它将以strlen(name)
作为第二个参数调用,而不是使用sizeof(name)
。
对于Windows世界中的同等产品,CPallini已经为您提供了正确的链接。
I want to set the name of my local host. I am using sethostname() function but I get an error as follows:
error C3861: ''sethostname'': identifier not found.
Below is the code snippet:
WSADATA wsa;
///Initialise winsock///
if (WSAStartup(MAKEWORD(2,2),&wsa) != 0)
{
//Socket Initialization Failed///
exit(EXIT_FAILURE);
}
char setname[128]="Ayesha-PC";
sethostname(setname, sizeof (setname));
解决方案
Are you looking for SetComputerNameEx[^]?
According to the winsock documentation[^] there is no such function.
You probably have seen that as example in a Unix-based application. There the function sethostname exists, (although it would be called withstrlen (name)
as second argument, and not withsizeof (name)
.
For an equivalent in the Windows world, CPallini has given you already the correct link.
这篇关于找不到sethostname标识符错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文