C++: Difference between revisions

2 bytes added ,  5 April 2020
Line 127: Line 127:
   std::istream my_file("my_file.txt");
   std::istream my_file("my_file.txt");
   std::string line;
   std::string line;
   # Read line by line
   // Read line by line
   # You can also read using <<
   // You can also read using <<
   while (getline(my_file, line)) {
   while (getline(my_file, line)) {
     std::cout << line << std::endl;
     std::cout << line << std::endl;