diff --git a/ProgUit Lab1/ProgUit Lab1.cpp b/ProgUit Lab1/ProgUit Lab1.cpp index 6b5c535..af7eb22 100644 --- a/ProgUit Lab1/ProgUit Lab1.cpp +++ b/ProgUit Lab1/ProgUit Lab1.cpp @@ -4,6 +4,8 @@ #include "histogram.h" #include "text.h" #include +#include + @@ -19,6 +21,9 @@ struct Input { Input + + + input_data(istream& hin, bool promt = false) { // Функция ввода //Создание переменных @@ -56,44 +61,48 @@ input_data(istream& hin, bool promt = false) { } +Input download(const string& address) { + stringstream buffer; + curl_global_init(CURL_GLOBAL_ALL); -int main(int argc, char* argv[]) -{ + CURL* curl = curl_easy_init(); + if (curl) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, address.c_str()); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + + if (CURLE_OK != 0) { + cout << curl_easy_strerror(res) << endl; + exit(1); + } - curl_global_init(CURL_GLOBAL_ALL); - CURL* curl = curl_easy_init(); + curl_easy_cleanup(curl); + } + + return input_data(buffer, false); +} - - if (argc > 1) { - if (curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, argv[1]); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - - if (CURLE_OK != 0) { - cout << curl_easy_strerror(res) << endl; - exit(1); - } - } - return 0; +int main(int argc, char* argv[]) +{ + + Input in; + if (argc > 1) { + in = download(argv[1]); } else { - + in = input_data(cin, true); } - - string promt; - bool promt1 = false; @@ -116,12 +125,10 @@ int main(int argc, char* argv[]) // Функция main - auto in = input_data(cin, promt1); // Ввод структуры auto bins = make_histogram(in.numbers, in.bin_count); // Распределние по корзинам show_histogram_svg(bins); // Вывод графика - curl_easy_cleanup(curl); diff --git a/x64/Debug/ProgUit Lab1.pdb b/x64/Debug/ProgUit Lab1.pdb index 68f6174..3b456fc 100644 Binary files a/x64/Debug/ProgUit Lab1.pdb and b/x64/Debug/ProgUit Lab1.pdb differ