I am trying to write a code that will continually prompt the user for their name and then prompt for their favorite quote. When the program reads the input it then stores the user name and quotes into a buffer that displays everything that the user inputted. It also ask the user "Any more quotes" and if the user inputs "no" it says "The buffer contains: " and list everything that the user has inputted. So far I have the entire code but I do not know how to access the shared buffers concurrently. Any help is wanted1
Do you mind if we see that code? That problem sounds like it could be solved with an std::vector<std::string> with no need for any shared buffers (assuming the "shared" portion refers to them being shared by threads).
-Albatross
P.S.: I'm enclosing a link to vectors, in case you don't know what they are but want to find out.
Thanks so much! But if I were to try to store it in a buffer how would I go about doing that? As of now when I run the program the only part that is stored in the buffer is the last thing I input. Is there anyway I could fix that?
//Albatross's Standard Vector Snippets
vector<string> vectorname; //Creates a new vector that stores strings.
vectorname.push_back(string somethingtoadd); //Adds a copy of a string onto the end of a vector.
vectorname.at(int i); //Accesses a stored string at location i.
You'll probably want use some combination of these snippets within your loop(s). :)