Skip to content

Instantly share code, notes, and snippets.

@m1irka
Created February 11, 2026 18:49
Show Gist options
  • Select an option

  • Save m1irka/d19ca250057e582b73e20a3b33db18b5 to your computer and use it in GitHub Desktop.

Select an option

Save m1irka/d19ca250057e582b73e20a3b33db18b5 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
#include <windows.h>
#include <urlmon.h>
#pragma comment(lib, "urlmon.lib")
using namespace std;
int main() {
const char* cities[10] = {
"odesa", "kyiv", "kharkiv", "lviv", "dnipro",
"zaporizhzhia", "vinnytsia", "chernihiv", "poltava", "sumy"
};
for (int i = 0; i < 10; i++) {
string srcURL = "https://wttr.in/" + string(cities[i]) + "?format=%t";
const char* destFile = "weather.txt";
if (URLDownloadToFileA(0, srcURL.c_str(), destFile, 0, 0) != S_OK) {
cout << cities[i] << ": Error downloading" << endl;
continue;
}
FILE* f;
fopen_s(&f, destFile, "r");
if (!f) {
cout << cities[i] << ": Error opening file" << endl;
continue;
}
char text[100];
if (fgets(text, sizeof(text), f)) {
cout << cities[i] << ": " << text;
}
fclose(f);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment