to get output of libcurl program

This is a discussion on to get output of libcurl program within the C++ Programming forums, part of the General Programming Boards category; I'm new to libcurl and trying to get output of sample program codes, but no result. Code: #include <stdio.h> #include ...

  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
    Katy, Texas
    Posts
    2,309
    You need to set up a writer. Look at curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, ....)
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

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, 10: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, 09: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


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21