Windows的hosts文件在哪里?

本文介绍了如何在Windows系统中找到并编辑hosts文件,通过添加IP地址和对应的主机名实现自定义域名解析。路径位于C:WindowsSystem32driversetc下。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

hosts文件主要是为了做IP地址和机器名映射!

习惯了Linux下面的位置/etc/hosts,一时间还找不到Windows的对应文件在哪。

这里这里:

C:\Windows\System32\drivers\etc

然后,直接编辑HOSTS文件,在最后添加需要的IP地址和机器名,保存即可!

10.1.10.1 myhostname1
10.1.10.2 myhostname2

OK!

1. 单链表的建立、插入、删除、查找运算思路结构: 定义单链表节点结构体: ``` struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} }; ``` 1.1 单链表的建立 ``` ListNode* createList(vector<int>& nums) { ListNode* head = new ListNode(0); ListNode* cur = head; for (int i = 0; i < nums.size(); i++) { ListNode* newNode = new ListNode(nums[i]); cur->next = newNode; cur = newNode; } return head->next; } ``` 1.2 单链表的插入 ``` void insertNode(ListNode* head, int val) { ListNode* newNode = new ListNode(val); newNode->next = head->next; head->next = newNode; } ``` 1.3 单链表的删除 ``` void deleteNode(ListNode* head, int val) { ListNode* cur = head; while (cur->next != NULL) { if (cur->next->val == val) { ListNode* temp = cur->next; cur->next = temp->next; delete temp; break; } cur = cur->next; } } ``` 1.4 单链表的查找 ``` ListNode* searchNode(ListNode* head, int val) { ListNode* cur = head->next; while (cur != NULL) { if (cur->val == val) { return cur; } cur = cur->next; } return NULL; } ``` 2. 循环单链表的建立、插入、删除、查找运算思路结构: 定义循环单链表节点结构体: ``` struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} }; ``` 2.1 循环单链表的建立 ``` ListNode* createList(vector<int>& nums) { ListNode* head = new ListNode(0); ListNode* cur = head; for (int i = 0; i < nums.size(); i++) { ListNode* newNode = new ListNode(nums[i]); cur->next = newNode; cur = newNode; } cur->next = head; return head->next; } ``` 2.2 循环单链表的插入 ``` void insertNode(ListNode* head, int val) { ListNode* newNode = new ListNode(val); ListNode* cur = head->next; while (cur->next != head) { cur = cur->next; } newNode->next = head; cur->next = newNode; head = newNode; } ``` 2.3 循环单链表的删除 ``` void deleteNode(ListNode* head, int val) { ListNode* cur = head; while (cur->next != head) { if (cur->next->val == val) { ListNode* temp = cur->next; cur->next = temp->next; delete temp; break; } cur = cur->next; } } ``` 2.4 循环单链表的查找 ``` ListNode* searchNode(ListNode* head, int val) { ListNode* cur = head->next; while (cur != head) { if (cur->val == val) { return cur; } cur = cur->next; } return NULL; } ```
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值