C++ Part 23

Using Getline

Reading From a Text File Using ifstream:

To read from a text file we need to include the fstream library and create an ifstream object which is placed in the std namespace.

#include <fstream>
using namespace std;  


#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main( )
   string Name, Website;
   string description;
   fstream inputStream;

   inputStream >> Name >> Website;
   inputStream >> description;
   cout << "Name: " << Name << "      "  << "Website: " << Website << endl;
   cout << "description: " << description << endl;
   return 0;

The input file is Website and must be in the same folder

NavidPlus https://NavidPlus.blogspot.com


Popular Posts