So I'm currently a second year computer engineering student and I've run into a massive wall with this C++ data structures class I'm currently enrolled in. This program I have to create should read data from a file, input that data into a vector and display the minimum and maximum for that file. She also wants me to use a template, but I'm just trying to get this thing off the ground before I traverse that road. Now the issue I'm having is I can't get anything going besides this point in my code.
Now this code is obviously incomplete, but I can't seem to figure out how to read these values into a vector and then throw the values that are strings. To be honest with you, I'm lost in the sauce and am, for lack of a better metaphor, throwing brown stuff against a wall and seeing if it sticks. I understand these topics individually, but combining them and throwing in a data file has me lost. If someone could take the time to sit down and help me work this out because my professor hasn't been answering my emails for a week (online only course) and this project is due on Tuesday and I've been working for the last 2 days and have NOTHING completed.
I'd greatly appreciate the assistance and understand I'm on the verge of losing it. I have no issues in my Java, Diff Eq or HTML/CSS course but this C++ course is absolutely dominating me (Received a B in the intro to C++ course). Thanks again and I appreciate anyone who can help!
//Nicholas Stafford
//COP2535.0M1
//Read in text file into multiple vectors and display maximum and minimum integers/strings.
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <algorithm>
using namespace std;
int main() {
ifstream inputFile; //File input object
const int fSize = 6;
int numCt = 0; //Counts number of integers
vector<int> numInt(fSize);
string numWd;
//Open input file
inputFile.open("minmax.txt");
//Data validation for file
if (inputFile)
{
//Try method to remove string values
try
{
//Only pull the integer values into a vector
while (inputFile >> numInt)
{
numCt++;
}
}
catch (string noString)
{
cout << noString;
}
}
}