找不到sethostname标识符错误。

编程入门 行业动态 更新时间:2024-10-23 05:48:50
本文介绍了找不到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));

解决方案

您是否正在寻找 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 with strlen (name) as second argument, and not with sizeof (name). For an equivalent in the Windows world, CPallini has given you already the correct link.

更多推荐

找不到sethostname标识符错误。

本文发布于:2023-10-07 15:25:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1469767.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标识符   找不到   错误   sethostname

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!