小编Sta*_*per的帖子

从特定URL获取IP

我正在尝试使用以下方法获取特定网址的IP地址:

var ip = Dns.GetHostAddresses("http://oldschool.runescape.com/game?world=321")[0];
Run Code Online (Sandbox Code Playgroud)

问题是这个函数似乎只适用于正常的主机地址(如函数所示,例如:www.runescape.com),它在使用这个特定的更深层的URL时会产生异常.是否有任何功能可以获取更具体的URL的IP?

提前致谢.

c# ip networking

4
推荐指数
1
解决办法
7734
查看次数

我的简单for循环有什么问题?

我的for循环遇到了一些麻烦,我想在for循环中的一个int数组中输入1个数字,循环4次.但是输出立即变为"请输入第4个数字",好像变量i从一开始就是4.

#include <iostream>
#include <string>
#include <iostream>

using namespace std;

void main()
{
    int PIN[4] = {};
    string txtNr ="1st";
    for(int i=0;i<4;i++)
    {
      if(i=0)
        txtNr = "1st";
      if(i=1)
        txtNr = "2nd";
      if(i=2)
        txtNr = "3rd";
      if(i=3)
        txtNr = "4th";
      cout << "Please enter the " << txtNr <<" number: ";
      cin >> PIN[i];
    }


        for(int i=0;i<4;i++)
        {
           cout << PIN[i] << endl;
        }
}
Run Code Online (Sandbox Code Playgroud)

有人知道吗?如果我输入一个数字,例如最后一个输出

0 0 0 1

c++ for-loop

-4
推荐指数
1
解决办法
135
查看次数

标签 统计

c# ×1

c++ ×1

for-loop ×1

ip ×1

networking ×1