I am using the following code to fetch response from my server and i want to send dynamic values in URL. How can I send the dynamic values through URL?
Code:
#include <stdio.h>
#include <curl/curl.h>
#include <curl/easy.h>
#include <curl/types.h>
size_t write_data_balance_amt(void *buffer, size_t size, size_t nmemb, void *userp);
int main(char card_no[10],char PIN[4])
{
CURL *curl;
CURLcode res;
card_no="123456789";
PIN="1234";
amount="1000";
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1 ); /* DEBUG - for those who RTFM */
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data_balance_amt);
curl_easy_setopt(curl, CURLOPT_WRITEDATA,&PIN );
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &card_no);
curl_easy_setopt(curl, CURLOPT_URL, (("http://192.168.100.74:8080/posserver/transaction?msgid=200&pin=")&PIN("&pname=deba&cardno=")&card_no("&cvv=111&amt=amount"));
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
return 0;
}
size_t write_data_balance_amt(void *buffer, size_t size, size_t nmemb, void *userp)
{
char *response;
response = (char*)buffer;
/* NOT \0 terminated, so use the passed size information */
printf("*********** %.*s\n",size*nmemb,response);
//lk_dispclr();
//lk_disptext(2,0,response,0);
return size * nmemb; /* V.Important */
}