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; |
//NavidPlus.blogspot.com
#include <iostream> #include <fstream> #include <string> using namespace std; int main( ) { string Name, Website; string description; fstream inputStream; inputStream.open("Website"); inputStream >> Name >> Website; inputStream >> description; cout << "Name: " << Name << " " << "Website: " << Website << endl; cout << "description: " << description << endl; inputStream.close(); return 0; } |
NavidPlus https://NavidPlus.blogspot.com
NavidPlus@Blogger |
No comments:
Post a Comment