code: сокращение ссылки в writedata

main
SukhotinMD 2 недель назад
Родитель 3de2094a93
Сommit 4ad958b62e

@ -60,6 +60,16 @@ input_data(istream& hin, bool promt = false) {
return in;
}
size_t
write_data(void* items, size_t item_size, size_t item_count, void* ctx) {
size_t data_size = item_size * item_count;
stringstream* buffer = reinterpret_cast<stringstream*>(ctx);
buffer->write(reinterpret_cast<const char*>(items), data_size);
return data_size;
}
Input download(const string& address) {
stringstream buffer;
@ -70,8 +80,14 @@ Input download(const string& address) {
CURL* curl = curl_easy_init();
if (curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
@ -92,6 +108,7 @@ Input download(const string& address) {
int main(int argc, char* argv[])
{
curl_global_init(CURL_GLOBAL_ALL);
Input in;
if (argc > 1) {

Двоичные данные
x64/Debug/ProgUit Lab1.pdb

Двоичный файл не отображается.
Загрузка…
Отмена
Сохранить