a. Prompts the user for the name of an output file in which to store some integers. b. Opens a file with that name. c. Prompts the user to enter a list of positive integers terminated by a -1. As the user enters a number, the program saves the number (including the -1) to the file. d. Closes the output file.
Second half:
a. Reopens the file as an input file. b. Checks to see if the file exists. If not, the program should exit. c. Reads the integers from the file and echoes them to the screen until the -1 is read. The program should not echo the -1. d. Closes the stream.
ifstream objects have the extraction operator overloaded so just the same way you read values using cin, you can use the ifstream object to do the same:
For the above to work, you have to have a -1 in your file, but with the way you have created your while loop on line 25, a -1 will never be stored in the file, so you have to fix that
@Smac89 Thanks, I forgot about that part! But I still have the problem of outputting the values in the program. I still need that part cleared up for me.