Thread: curl problem

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    1

    curl problem

    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 */
    }

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Moved into a new thread. Please leave old threads closed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM