67 238
Assignments Done
99,2%
Successfully Done
In November 2018

Answer to Question #72076 in C++ for Dhvani

Question #72076
Write a C++ code which reads the contents of a text file “first_file.txt”
Expert's answer
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
using namespace std;

int main(int argc, char* argv[])
{
vector<string> data;
ifstream input_file("first_file.txt", ios::in);
string temp;

if(input_file!=NULL)
{
while(!input_file.eof())
{
input_file>>temp;
data.push_back(temp);
}
}
else
cout<<"Can't open first_file.txt"<<endl;


return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions