Source Code File 03-07_curlerror3.c

#include <stdio.h>
#include <stdlib.h>
#include <curl/curl.h>

int main()
{
    CURL *curl;
    char url[] = "odd://site.com";

    /* Initialize easy curl */
    curl = curl_easy_init();
    if( curl == NULL)
    {
        fprintf(stderr,"Unable to init\n");
        exit(1);
    }

    /* set options */
    curl_easy_setopt(curl, CURLOPT_URL, url);

    /* curl the resource */
    curl_easy_perform(curl);

    /* cleanup */
    curl_easy_cleanup(curl);

    return(0);
}

Notes

* This code lacks error-checking on the result of the curl_easy_perform() function. Because the URL is invalid, no output appears to inform the user.

* Wide version of this code (statements not split)