| No. | Title and link |
|---|---|
| 1. | Introduction to C++ |
| 2. | Variables, branching, and loops |
| 3. | Functions and recursions |
| 4. | Pointers |
| 5. | Linked lists |
| 6. | Stacks |
| 7. | Sequences |
| 8. | Pointers practice |
| 9. | References |
| 10. | Sorting |
| 11. | Object oriented programming |
| 12. | Trees in C++ |
| 13. | Balanced trees |
| 14. | Sets and maps: simplified |
| 15. | Sets and maps: standard |
| 16. | Dynamic programming |
| 17. | Vectors |
| 18. | Representation of integers in computers |
| 19. | Floating point representation |
| 20. | Templates |
| 21. | Inheritance |
| 22. | Pointers to functions |
| 23. | Multi core programming and threads |
| 24. | Reading data from internet |
| 25. | Graphic cards and OpenCL |
| 26. | OpenCL on AWS |
| 27. | OpenCV and optical mark recognition |
24. Reading Data from Internet
cURL library
The library cURL is needed to read documents from internet.
Install the library using one of the following commands (one of them should hopefully work):
sudo apt install curl
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libcurl4-gnutls-dev
Example of a program that reads data from a website
// visitURL.cpp
// compile with
// c++ visitURL.cpp -o vurl -lcurl -std=c++11
// execute with
// ./vurl
#include <iostream>
#include <string>
#include <fstream>
#include <curl/curl.h>
static size_t f(void *p, size_t s, size_t m, void *u)
{
((std::string*)u)->append((char*)p, s * m);
return s * m;
}
std::string readFromURL(const std::string & mainLink){
CURL *curl;
std::string result;
curl = curl_easy_init();
if(curl) {
const char* linkArrayChar=mainLink.c_str();
curl_easy_setopt(curl, CURLOPT_URL, linkArrayChar);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, f);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, & result);
curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
return result;
}
int main(){
std::string res=readFromURL("https://imomath.com/");
std::cout<<res<<"\n";
return 0;
}