I've been searching all around but I didn't found a link about this.

I want to get a html, and use like it was a .txt in fopen, so that I can read it.

Does anyone knows how to do this in C? I can use a .html in fopen but only if I manually save the page and specify the path where it is.

Since now thanks!

8 Years
Discussion Span
Last Post by IsharaComix

Are you trying to read an HTML file from the web?

You may want to look at the curl library ( http://www.libcurl.org/ ). It will allow you to collect data directly from a URL in a pretty user-friendly fashion.

/* Downloads a webpage's html and saves it to a file 'out.html'. */
#include <curl/curl.h>
#include <stdio.h>
#include <stddef.h>

int main(void)
    CURL *c;
    FILE *f;
    f = fopen("out.html","w");

    c = curl_easy_init();
    curl_easy_setopt( c, CURLOPT_URL, "http://www.gnu.org/copyleft/gpl.html" );
    curl_easy_setopt( c, CURLOPT_WRITEDATA, f );
    curl_easy_perform( c );

    fclose( f );
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.