Hey guys, I'm trying to write a program to read an unknown number of values from a user-specified file, and save them so that the program can later determine their mean value. I'm failing this class, and I don't understand what's going on. I figured I should use a vector, since the assignment speficied that the number of values can be anything up to 1000, so there's no set limit. This is the best I've been able to do:
------------------This part is meant to open the file---------------------------
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
system ("Pause");
return 0;
}
--------------------------------------------------------------------------------
-------------------------This part is meant to declare the vector and read/store the values-----------------------------------------------------------
using namespace std;
int main () {
vector <double> fileValues (1000);
system ("Pause");
return 0;
}
--------------------------------------------------------------------------------
Obviously these are very rudimentary and wouldn't work very well. I'm in this class because I have to gave a computer science credit, it's not related to my degree and I've never done anything even remotely related to programming before. Once I know how to extract the values and save them to the array, i think I could manage to perform the mathematical operations, but it's getting to that step that's driving me nuts. Any help at all, or a push toward a useful resource, would be greatly appreciated. It's my last semester and I can't afford to fail!
Hmm... I think... do you have a book that you can read? That would probably be the fastest way to learn everything you need to know before the class finishes. I know this isn't the answer you want, but if you need to know it all fast, then reading a book is the way to go. Otherwise, you could search the forums. There have been plenty of questions like this.
Yeah, I'm using the book to try to get up to speed before the class ends, but right now I'm just trying to bang out this assignment, which is past due.