Source Code File 03-03_follow1.c

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

int main()
{
    CURL *curl;
    CURLcode r;
char url[] = "http://c-for-dummies.com/curl_test.txt";

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

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

    /* curl */
    r = curl_easy_perform(curl);
    if( r!=CURLE_OK )
    {
        fprintf(stderr,"Curl fail");
        exit(1);
    }

    /* cleanup */
    curl_easy_cleanup(curl);

    return(0);
}

Notes

* This code fails as the url[] string is an invalid (old) address.

* Wide version of this code (statements not split)