所以我有这个程序可以找到我电脑的外部 IP 地址。我需要将此数据写为变量,但我不知道如何。这是来源(我已经知道过多的标题,它们都被同时使用过,我还没有清理它。)
#include <stdio.h>
#include <C:\Documents and Settings\Jacob Grass\My Documents\C++\Server Software\curl\curl.h>
#include <C:\Documents and Settings\Jacob Grass\My Documents\C++\Server Software\curl\types.h>
#include <C:\Documents and Settings\Jacob Grass\My Documents\C++\Server Software\curl\easy.h>
#include <stdlib.h>
#include <unistd.h>
#include <windows.h>
#include <iostream>
#include <fstream>
//http://www.cplusplus.com/forum/windows/36638/
//http://bot.whatismyipaddress.com/
using namespace std;
int ipfetch (void)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init ();
if (curl)
{
curl_easy_setopt (curl, CURLOPT_URL, "http://bot.whatismyipaddress.com/");
res = curl_easy_perform (curl);
curl_easy_cleanup (curl);
}
return 0;
}
int main (){
while(1){
ipfetch();
//Sleep in milliseconds
Sleep(300000);
cout<<"\n";
}
}
任何帮助,将不胜感激。