New to C++, have a project where I have to read an input file with baseball statistics on it (done), but then place those values into an array. Figured vectors would be better, but really new to them, not really sure how they work.
My code is posted below. Not only do I get an error when I use "string names" in the function arguments, but I get an error when I try to use "names.push_back(firstName)".
I basically want to make it so that every time this loop iterates (goes through one line in the text file), it stores all of the different variables in different arrays/vectors.
Here's the code. I'm COMPLETELY lost! Also, what are some good ways to retain changes in the values of variables in a while loop? If you see, I had to use increments and decrements to do so.
// main.cpp
// Baseball Statistics
//
//
//
// Step 1: Vector/Dynamic Array Length. Use to set the number of elements to numbers of players (iterations).
// Step 2: Store information in different arrays.
// Step 3: Sort (Insertion) by last name, or stats?
// Step 4:
//
//
//---------------------------------------------------------------------------------------------------------------------
cout << "What Is The Name Of The Next File You Would Like To Open? File Names Are Case-Sensitive. Enter 'Exit' To Exit At Any Time." << endl;
cin >> fileName;
if (fileName == "Exit")
exit(0);
cout << "What Is The Name Of The Next File You'd Like To Save To? Do NOT Use The Same Location As The File You Want To Open. Enter 'Exit' To Exit At Any Time." << endl;
cin >> saveFile;
if (saveFile == "Exit")
exit(0);
while (saveFile == fileName)
{
cout << "Error. Please Try Again. Be Sure To Not Create A File With The Same Name As An Existing File." << endl;
cout << "What Is The Name Of The Next File You Would Like To Open? File Names Are Case-Sensitive. Enter 'Exit' To Exit At Any Time." << endl;
cin >> fileName;
if (fileName == "Exit")
exit(0);
cout << "What Is The Name Of The Next File You'd Like To Save To? Do NOT Use The Same Location As The File You Want To Open. Enter 'Exit' To Exit At Any Time." << endl;
cin >> saveFile;
if (saveFile == "Exit")
exit(0);
}
cout << "\tOpening File . . . \n";
else
cout << "Error. Please Enter A Valid File Name. Make Sure To Use Extensions." << endl;
cout << "What Is The Name Of The File You Would Like To Open? File Names Are Case-Sensitive. Enter 'Exit' To Exit At Any Time." << endl;
cin >> fileName;
if (fileName == "Exit")
exit(0);
cout << "What Is The Name Of The Next File You'd Like To Save To? Do NOT Use The Same Location As The File You Want To Open. Enter 'Exit' To Exit At Any Time." << endl;
cin >> saveFile;
if (saveFile == "Exit")
exit(0);
while (saveFile == fileName)
{
cout << "Error. Please Try Again. Be Sure To Not Create A File With The Same Name As An Existing File." << endl;
cout << "What Is The Name Of The Next File You Would Like To Open? File Names Are Case-Sensitive. Enter 'Exit' To Exit At Any Time." << endl;
cin >> fileName;
if (fileName == "Exit")
exit(0);
cout << "What Is The Name Of The Next File You'd Like To Save To? Do NOT Use The Same Location As The File You Want To Open. Enter 'Exit' To Exit At Any Time." << endl;
cin >> saveFile;
if (saveFile == "Exit")
exit(0);
}