#include<iostream>
#include<vector>
#include <fstream>
#include<string>
#include <atlstr.h>
#include <windows.h>
#include <urlmon.h>
#include <atlconv.h>
#pragma comment(lib,"Urlmon.lib")
using namespace std;
int main() {
std::ifstream infile("url\\new1.txt");
std::vector<std::string> address;
std::string url;
char name[100];
int flag = 0;
while (infile >>url) {
flag++;
size_t len = url.length();
int nmlen = MultiByteToWideChar(CP_ACP, 0, url.c_str(), len + 1, NULL, 0);
wchar_t* buffer = new wchar_t[nmlen];
MultiByteToWideChar(CP_ACP, 0, url.c_str(), len + 1, buffer, nmlen);
sprintf_s(name, "target\ %d.jpg",flag);
char * szStr = &name[0];
CString str = CString(szStr);
USES_CONVERSION;
LPCWSTR wszClassName = A2CW(W2A(str));
str.ReleaseBuffer();
HRESULT hr = URLDownloadToFile(NULL, buffer, wszClassName, 0, NULL);
int num = 0;
if (hr == S_OK)
{
cout << num<<endl;
num++;
}
}
return 0;
}
My dog training set: