Stian Olsen
Stian Olsen

Reputation: 1987

How to fetch text file from http into variable

(im a newbie in c)

I was wondering how i can fetch text in .txt file located on the web, into a variable. I was looking on libcurl or something, but couldnt find out how to use it on Peppermint Os (based on Ubuntu/Debian).

Anyone who can help me out?

Upvotes: 0

Views: 81

Answers (1)

Jonatan
Jonatan

Reputation: 2886

If you don't absolutely need to do the downloading inside your program, you could simply download the file using wget or curl and then pipe the output to STDIN of your program, from where you store the input in a variable.

This would allow you to use any file (from the web or not) as input.

Upvotes: 1

Related Questions