My instructions are as follows...
1) Start a program to work with points. Begin by defining the data type Point that has two coordinate members 'x' and 'y'.
2) Prompt the user to input seven (x,y) pairs. As the data is entered, store it in a vector of Points called original_points.
3) Print the data in original_points to see what it looks like.
4) Open an ofstream and output each point to a file named mydata.txt.
...
I'm extremely new to working with files and I don't know how to have my program output the data to a given file. Do I have to make a file mydata.txt to output to, or does the program do it itself? Where can I view the file that the program makes?
> Do I have to make a file mydata.txt to output to, or does the program do it itself?
The program ( ofstream ost{ oname }; ) will create the file if it does not exist.
> Where can I view the file that the program makes?
Open the file in a text editor and have a look at at.
Or if you want its contents to be displayed on the console at the end of the program,
add this line just before the last closing brace on line 64: std::cout << "\n-----------\n\n" << std::ifstream( "mydata.txt" ).rdbuf() ;
> Do I have to make a file mydata.txt to output to, or does the program do it itself?
The program ( ofstream ost{ oname }; ) will create the file if it does not exist.
> Where can I view the file that the program makes?
Open the file in a text editor and have a look at at.
Or if you want its contents to be displayed on the console at the end of the program,
add this line just before the last closing brace on line 64:
std::cout << "\n-----------\n\n" << std::ifstream( "mydata.txt" ).rdbuf() ;
where can I find the file to open it in a text editor? I couldn't find it anywhere I looked.