array text line by line code example
Example 1: python read file line by line
with open("file.txt") as file_in:
lines = []
for line in file_in:
lines.append(line)
Example 2: c++ read file line by line
#include <iostream>
#include <ifstream>
#include <string>
using namespace std;
ifstream file("file.txt");
if (file.is_open())
{
string line;
while (getline(file, line))
{
// note that the newline character is not included
// in the getline() function
cout << line << endl;
}
}