Wednesday, January 29, 2020

CPP: Read file using ifstream

#include<iostream>
#include<fstream>
int main()
{
std::ifstream file_txt("file.txt");
for(std::string line; std::getline(file_txt, line);)
{
std::cout << line << std::endl;
}
return 0;
}
view raw ifstream.cpp hosted with ❤ by GitHub


To build:
$: clang++ ifstream.cpp

Generate a file to read:
$: echo "hello world" > file.txt

Run it:
$: ./a.out

No comments:

Fedora install screen chronicle

Fedora install screen chronicle Below are links to Fedora installation screens. It is interesting to see how it has evolved over time. Fe...