Thread: to get output of libcurl program

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    3

    to get output of libcurl program

    I'm new to libcurl and trying to get output of sample program codes, but no result.
    Code:
    #include <stdio.h>
    #include <curl/curl.h>
     
    int main(void)
    {
      CURL *curl;
      CURLcode res;
     
      curl = curl_easy_init();
      if(curl) {
        curl_easy_setopt(curl, CURLOPT_URL, "http://google.com");
        res = curl_easy_perform(curl);
     
        /* always cleanup */ 
        curl_easy_cleanup(curl);
      }
      return 0;
    }
    I'm using the following steps:
    To compile: g++ sample.cpp -lcurl -o sample
    To execute: ./sample
    The program is compiled successsfully and after executing it returns to the promt again without showing any output.
    Plz help.

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    You need to set up a writer. Look at curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, ....)
    Mainframe assembler programmer by trade. C coder when I can.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with a Battleship Program
    By HBlakeH in forum C Programming
    Replies: 1
    Last Post: 12-05-2010, 11:13 PM
  2. Replies: 1
    Last Post: 05-29-2010, 05:24 AM
  3. program looping with final output
    By hebali in forum C Programming
    Replies: 24
    Last Post: 02-28-2008, 10:58 AM
  4. Replies: 3
    Last Post: 09-05-2005, 08:57 AM
  5. Redirecting program output straight to an edit control
    By bennyandthejets in forum C++ Programming
    Replies: 5
    Last Post: 07-05-2004, 08:25 AM

Tags for this Thread