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:

Configuring TUN/TAP virtual network interface for use with QEMU on Xubuntu 24.04

Configuring TUN/TAP virtual network interface for use with QEMU on Xubuntu 24.04 I am planning to run qemu-system-ppc to play around QEMU ...