libcurls http 投稿で post_data1 を送信しようとすると、間違ったパスワードが表示されますが、post_data2 で固定式を使用するとログインするという問題があります。両方を計算すると、それらはまったく同じ文字列になります..
libcurl がそれらをヘッダーに入れたときに、なぜそれらが同じではないのか、誰か教えてもらえますか? または、そうである場合、送信する前になぜそれらが異なるのか。
string username = "mads"; string password = "123";
stringstream tmp_s;
tmp_s << "username=" << username << "&password=" << password;
static const char * post_data1 = tmp_s.str().c_str();
static const char * post_data2 = "username=mads&password=123";
std::cout << post_data1 << std::endl; // gives username=mads&password=123
std::cout << post_data2 << std::endl; // gives username=mads&password=123
// Fill postfields
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post_data1);
// Perform the request, res will get the return code
res = curl_easy_perform(curl);