This is my code so far. how do i make it so the first user can type in "5 6 pick up sticks" then the user will exit the program by pressing return twice and then the second user will compile the program and will see what the first user had input and then enter "7 8 ain't c++ great!" and so forth. so the first person who runs the program should see some advice/words on the screen. the 2nd user will then see it and continue then close the program. the first user should then see the previous messages and so forth.
i was thinking of appending the file but everything i learned has to do with a file. i can get it into the file but i can't get the user to input words into the screen rather than the file. i was also thinking of using a function, but im not really sure.
i know i need a cin but im not so sure where to put it.
Does this make any sense? please ask me to clarify.
#include <iostream>
#include <stdlib.h>
#include <fstream>
using namespace std;
int main ()
{
cout << "Opening data.txt for appending\n";
ofstream fout;
fout.open("data.txt", ios::app);
if (fout.fail())
{
cout << "Input file opening failed.\n";
}
fout << "5 6 pick up sticks. \n"
<< "7 8 ain't c++ great!\n";
fout.close();
cout << "End of appending to file.\n";
Make your code so that whatever the first user writes, will be written on a *.txt file, and so on and so on... so that the next user will read whatever the previous ones wrote. But the code I am thinking of will show you from the advice that the first one wrote till the last one before the one currently compiling this program!
example
First user wrote
1 2 Bla Bla Bla..
This will be written on a file.
The next user who compiles will get that message. When he writes
3 4 Bla Bla Bla
the next user to read will get the first and 2nd advice.. and so on until it's done :)
can someone please help me edit my code to give me an example because i am not sure exactly what it looks like. this is my code, but it doesn't seem to work..