Notes from stdin
mediumQuestion 663Write a program that reads lines from standard input until the input ends, stores them in a file, then reads the file back through the same fstream object and prints the numbered notes.
1. Open notes.txt with an fstream in ios::in | ios::out | ios::trunc mode.
2. Read every line from cin with getline and write each one to the file followed by a newline.
3. Move the read position back to the start with seekg(0).
4. Read the file line by line with getline and print each line as N: text, where N starts at 1 (a colon and a single space after the number).
Input: one note per line, for example: milk eggs
For that input the program prints the output shown in Expected Output.
Expected output
1: milk 2: eggs 1: call mom 2: buy bread 3: pay rent
= newline. The output ends with a newline, so print one after the last line.
Your output
Run your code to see the output here...