Data read by libcurl functions can be saved to an open file or stored in memory, depending on how various options are set. When configured to save information to a file, the file is written using whatever data is read from the web. When configured to save information to memory, a special function is used to monitor the bytes read and increase the buffer size as new data arrives.
- Unless you direct it to do otherwise, … text generated by the libcurl function … curl_easy_perform is sent to standard output. … You can, however, save the text to a file … or redirect it to a buffer … providing you set the proper libcurl options. … So this code fetches information from a webpage … and saves it to a file. … The file is opened at line 14 … by using standard C library functions. … The libcurl easy interface is initialized … at line 22, … followed by various options. … At line 26, … the URL is specified. … At line 32, … the WRITEFUNCTION is set to the NULL pointer, … which directs libcurl to look for a file handle, … which is set at line 35. … So the output it sent to the open file … and not to standard output. … The file opened is closed at line 48. … And line 50 outputs a message to the user, … otherwise the program runs successfully … and would generate no output. … Now, I've already compiled the program. … So, we'll run it to see what it does. … It fetches the data, …
Author
Released
10/1/2019- Finding, installing, and linking libraries
- Accessing and generating XML data
- Working with JSON
- Working with the libcurl library
- Text programming
- Reading, writing, and manipulating JPEG images
- Working with PNG images
Skill Level Advanced
Duration
Views
Related Courses
-
Code Clinic: C
with Dan Gookin1h 7m Intermediate
-
Introduction
-
Using the exercise files1m 2s
-
Working with the code2m 45s
-
1. Setup and Configuration
-
Understanding libraries2m 50s
-
Finding a C library2m 44s
-
Installing a library4m 15s
-
Liking a library: IDE4m 10s
-
-
2. Data Structures
-
Understanding XML2m 23s
-
Accessing XML data3m 26s
-
Generating XML data3m 57s
-
Working with JSON2m 39s
-
Accessing JSON data3m 10s
-
Reading JSON data3m 46s
-
Creating JSON output3m 35s
-
-
3. Web Access
-
Testing libcurl2m 3s
-
Fetching a web page3m 47s
-
Saving web data3m 31s
-
Sending data2m 35s
-
-
4. Text Programming
-
Working with wide characters3m 19s
-
Building an ncurses program2m 27s
-
Controlling the text screen2m 32s
-
Making color text2m 56s
-
Exploring ncurses input4m 6s
-
-
5. Computer Graphics
-
Accessing a JPEG2m 31s
-
Manipulating JPEG images3m 5s
-
Working with PNG images3m 57s
-
Modifying a PNG image2m 26s
-
-
Conclusion
-
Writing your own library4m 19s
-
Next steps1m 17s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Saving web data