0
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <vector>
using namespace std;

int getInputFileName(); //function to get and store content in file to vector
int getOutputFileName();

int main()
{
getInputFileName();
getOutputFileName();
}

int getInputFileName()
{
vector<Student> s;
ifstream input;
string inputFileName;

cout << "What is the name of the input file you are going to use: " << endl;
cin >> inputFileName;

input.open(inputFileName);

while (input.fail()) // check to see if inputFileName opened
{
    cout << "Error! Incorrect file name." << endl;
    cout << "Enter the correct name of the input file you want to use: " << endl;
    cin >> inputFileName;
}

can someone help me in this for loop right here? I need to read the contents of the file into the vector s. I am a little confused on vectors because I was absent the day my professor went over them. I'm not sure how to read the file into vector. Please help and don't be too rough on me, thank you in advance!!

for(i = 0; i > )
}

int getOutputFileName()
{

ofstream output;
string outputFileName;

cout << "What is the name of the output file you are going to use: " << endl;
cin >> outputFileName;

output.open(outputFileName);

while (output.fail())  // check to see if inputFileName opened
{
    cout << "Error! Incorrect file name." << endl;
    cout << "Enter the correct name of the output file you want to use: " << endl;
}
}
mykee7997
  • 1
  • 1
  • You have a loop to get the user to input a correct filename, but you never reopen the actual file inside the loop. – Some programmer dude Apr 18 '16 at 22:32
  • And how are those functions opening the files relevant to the problem you seem to be asking about, reading into a vector? Please [read about how to ask good questions](http://stackoverflow.com/help/how-to-ask), and learn how to create a [Minimal, Complete, and Verifiable Example](http://stackoverflow.com/help/mcve). And if you search a little, I'm sure you could find a nice [reference](http://en.cppreference.com/w/cpp/container/vector) or maybe a [good book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – Some programmer dude Apr 18 '16 at 22:33
  • @joachimPileborg thanks, i forgot about that. – mykee7997 Apr 18 '16 at 22:33

0 Answers0