Im trying to write a function for another program that reads the name, score and date to a txt file, then display it as a sort of "scoreboard". How would I do this in a function to be called to the main?
Are you saying you need to create a function that reads from a file, and displays that information on the console? Have you already created an input file stream? Are you having trouble getting the data? I don't know which part you are stuck on, or if you possibly have no idea where to begin.
Very confused with syntax and how sequential files work, but basically I need to create a function for another program that reads the name, score, and date into a file, then displays those 3 things line by line
I guess you mean reading from a txt file not to. But what does your "phrase" scoreboard mean? If you mean just a display pattern then you task is easy, if your data is arranged inform of the name score and date per line then you can use the getline function to read each line into a string a display the string., loop unitil the whole file is read.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
void display ()
{
ifstream in ("scoreboard.txt");
string current="";//always a good Idea to intialize your variables
if (!in){cout <<" text file not found"; exit (1);}
while (in)
{
getline (in, current, '\n');
cout <<current <<endl;
}
in.close ();
}
That was just to give you an idea, you can start there and feel free to modify that to suite your need;
Some good reference too will be handy to get you started
http://www.cplusplus.com/doc/tutorial/files/
Here is something quick I came up with. Feel free to use the link Andy gave you as well. I also found this: http://www.cplusplus.com/forum/articles/6046/
It looks like you have just broke the tip of the iceberg. Have fun.