lab4
KhodiukMR 11 месяцев назад
Родитель fe6d5ade72
Сommit ac8f41c554

@ -9,6 +9,7 @@
using namespace std;
struct Input {
vector<double> Numbers;
size_t BinCount{};
@ -48,21 +49,29 @@ WriteData(void* items, size_t item_size, size_t item_count, void* ctx) {
}
Input
Download(const string& address) {
Download(const string& address, const string& option) {
stringstream buffer;
if ((option != "") && (address != "-verbose") && (option != "-verbose")) {
cout << "õóéíþ òû ïèøåøü, ïèøè îïöèþ -verbose, äààóí" << endl;
exit(2);
}
CURL* curl = curl_easy_init();
if (curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteData);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
if (address == "-verbose" || option == "-verbose") {
curl_easy_setopt(curl, CURLOPT_VERBOSE, option == "-verbose" ? option.c_str() : address.c_str());
}
res = curl_easy_perform(curl);
if (res != CURLE_OK) {
cout << curl_easy_strerror(res);
exit(1);
}
curl_easy_cleanup(curl);
}
@ -72,10 +81,11 @@ Download(const string& address) {
int main(int argc, char* argv[]) {
setlocale(LC_ALL, "Russian");
double MaxCount = 0;
Input in;
if (argc > 1) {
in = Download(argv[1]);
in = Download(argv[1], argv[2]);
}
else {
in = InputData(cin, true);

Загрузка…
Отмена
Сохранить