//#include "stdafx.h" // uncomment this line if using visual studio
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
fstream reader;
reader.open("text.txt");
string output;
if (reader)
{
while (!reader.eof())
{
reader >> output;
cout << output;
}
}
else
{
cout << "File Does Not Exist\n";
return 1;
}
reader.close();
system("PAUSE");
return 0;
}
//#include "stdafx.h" // uncomment this line if using visual studio
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
fstream reader;
reader.open("text.txt");
string output;
if (reader)
{
while (!reader.eof())
{
reader >> output;
cout << output;
}
}
else
{
cout << "File Does Not Exist\n";
return 1;
}
reader.close();
system("PAUSE");
return 0;
}
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
int main()
{
fstream file;
file.open("questions.txt");
vector<string> questions;
if (file)
{
while (!file.eof())
{
string temp;
getline(file, temp);
questions.push_back(temp);
}
}
else
{
cout << "File Does Not Exist\n";
return 1;
}
for(int i = 0; i < questions.size(); i++) //Or you could just do cout << questions[numberOfQuestion] << endl;
cout << questions[i] << endl;
file.close();
return 0;
}
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
int main()
{
fstream file;
file.open("questions.txt");
vector<string> questions;
if (file)
{
while (!file.eof())
{
string temp;
getline(file, temp);
questions.push_back(temp);
}
}
else
{
cout << "File Does Not Exist\n";
return 1;
}
for(int i = 0; i < questions.size(); i++) //Or you could just do cout << questions[numberOfQuestion] << endl;
cout << questions[i] << endl;
file.close();
return 0;
}
Copyright © 2024, NextGenUpdate.
All Rights Reserved.