Can anyone help me solve about this error? im still new at c++ programming, and im using C++/CLR to make button click event, also try to use curl library to get some http request. but instead i got that exception throw.
this is my button click code:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
System::String^ username = textBox1->Text;
System::String^ password = textBox2->Text;
CURLcode res;
std::string readBuffer;
System::String^ read;
curl_global_init(CURL_GLOBAL_ALL);
CURL* curl = nullptr;
curl = curl_easy_init();
if (curl)
{
//std::cout << url;
curl_easy_setopt(curl, CURLOPT_URL, "www.google.com");
curl_easy_setopt(curl, CURLOPT_WRITEDATA, readBuffer);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writer);
CURLcode code = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
curl_global_cleanup();
}
and this is my write function outside button event:
int writer(char* data, size_t size, size_t nmemb, std::string* writerData)
{
if (writerData == NULL)
return 0;
writerData->append(data, size * nmemb);
return size * nmemb;
}
it got no error when i run it works fine, but after i click the button it shows error
User contributions licensed under CC BY-SA 3.0