Good day everyone. My code is working fine until I have to use a variable as value for a header. Wanna know on how to use a variable as value in header. I have searched ton already but couldnt find an example on the correct format on how to use a variable as part of a header. This is the part of my codes(the codes are working well without the variable as key, but when the need to use comes, the code doesnt return anything, just blank window without any error.)
// my imports and write callback here
int seconds;
int main()
{
time_t seconds;
seconds = time(NULL);
cout << "Time: " << seconds;
CURL* curl = curl_easy_init();
struct curl_slist* header = NULL;
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, "mytestwebsite.com");
header = curl_slist_append(header, "Timestamp: " + seconds); // THIS seconds variable here.
// some other headers to append
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
cout << "Response 1: " << seconds;
curl_easy_cleanup(curl);
}
return 0;
{
Hoping to hear from my helpful brothers! Thanks in advance!