123456789101112131415161718192021222324252627
#include <iostream> #include <string> #include <curl/curl.h> const char* const Address {"http://requestbin.net/r/XXXXXXXX"}; void sendRequest(const std::string& str) { curl_global_init(CURL_GLOBAL_ALL); CURL *curl = curl_easy_init(); if (curl) { curl_easy_setopt(curl, CURLOPT_URL, Address); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, str.c_str()); CURLcode res = curl_easy_perform(curl); if (res != CURLE_OK) std::cerr << "curl_easy_perform() failed: " << curl_easy_strerror(res) << '\n'; curl_easy_cleanup(curl); } curl_global_cleanup(); } int main() { std::string str; std::cout << "Enter string: "; std::getline(std::cin, str); sendRequest(str); }
1234567891011121314151617181920212223242526272829