Getting a FILE* from a std::fstream

The short answer is no. The reason, is because the std::fstream is not required to use a FILE* as part of its implementation. So even if you manage to extract file descriptor from the std::fstream object and manually build a FILE object, then you will have other problems because you will now have two buffered … Read more

How to read a file line by line or a whole text file at once?

You can use std::getline : #include <fstream> #include <string> int main() { std::ifstream file(“Read.txt”); std::string str; while (std::getline(file, str)) { // Process str } } Also note that it’s better you just construct the file stream with the file names in it’s constructor rather than explicitly opening (same goes for closing, just let the destructor … Read more

mmap() vs. reading blocks

I was trying to find the final word on mmap / read performance on Linux and I came across a nice post (link) on the Linux kernel mailing list. It’s from 2000, so there have been many improvements to IO and virtual memory in the kernel since then, but it nicely explains the reason why … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)