Please bear with me as I have to be honest and say this isn't my best subject and I'm struggling with some aspect of it.
What I need to do is to get test scores write to a file and then in another program write a file to sort and group the scores within a range. Pretty comfortable with the second part, what I'm having difficulties with is the first part, getting and writing the scores to an file. The file does exist, but there is no data in it when I enter it.
Awesome, Thanks Kyle. I wasn't sure if it should have been in or out of the loop.
Now it does record the array numbers, but they're all together with no spaces. Will the next program that needs to read them be able to tell the elements apart?
the cout << endl; had been removed when I was trying some different things.
Putting it back in fixed the issue. Thanks again, looks Like I can start the 2nd part. Big props.
I really want to write this whole thing by myself as much as I can. Other programs we have done, while i have done the work, I have also looked at the programs which are listed all over the internet, so I want this to be entirely my own.
O.K. Need advice again. Think this is correct way to open it, not 100% sure though. What I'm lacking now is how to access the array's information. When I do what I did below it displays the contents of some other file. Also the file is .out, so is that correct format ("scores.out")? What I'm trying to do is to make sure that I'm pulling the right information so that I can then put in the loop and manipulate it the way I need to.
Nah, just have to figure how to compare the information to manipulate it, but that's in the book and on the web so I really should be able to do that part.
Thanks again.
If I use a while != EOF type statement, does it automatically recognize the EOF? Or should I use a marker like -999 and extend the array by one element and add -999?
OK now I'm getting frustrated, and that's not good. :) I'm trying to get it to read the values with a loops, but it's only reading the first value. Honest, this is last thing I'll ask for help with! :)
Below is basically what I'm trying to do.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <cstdlib>
#include <iostream>
#include <fstream>
usingnamespace std;
int i;
int main(int argc, char *argv[])
{
ifstream infile;
infile.open("scores.txt");
for (i=0; i < 26; i++);
int score;
infile >> score;
cout << score;
system("PAUSE");
return EXIT_SUCCESS;
}
If I recall correctly, Ctrl-F5 (or was it just F5?) runs a program in debug mode. Else, there should be a green arrow to run the program. C++ wasn't meant to be interpreted by anything else than a compiler, so... :/