Created
April 13, 2026 19:47
-
-
Save XoLinA/f5654b7440bfebee1979bd27be34f12b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <windows.h> | |
| #include <urlmon.h> | |
| #include <string> | |
| #include <ctime> | |
| #pragma comment(lib, "urlmon.lib") | |
| using namespace std; | |
| int main() { | |
| cout << "Press SPACE to download an image..." << endl; | |
| cin.get(); | |
| string desktopPath = "C:\\Users\\Хозяин\\Desktop"; | |
| string filename = desktopPath + "\\cat_" + to_string(time(0)) + ".jpg"; | |
| const char* image_url = "https://cataas.com/cat"; | |
| HRESULT hr = URLDownloadToFileA(NULL,image_url,filename.c_str(), 0,NULL); | |
| if (SUCCEEDED(hr)) | |
| { | |
| cout << "Image downloaded successfully!" << endl; | |
| cout << "Saved to: " << filename << endl; | |
| } | |
| else | |
| { | |
| cout << "Download failed!" << endl; | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment