I need help to write a program that allows a user to use
the keyboard to input the first and last names
of 40 friends, up to 50 characters each. I need
to display the names 15 at a time, pausing to let
the user press a key before the list continues.
I got the names but the code is something different, could someone help me get started?
Oh my god this was a pain, also this was not my idea it is just required my my teacher
Well. This is a bizzare project. It's extremely simple, but you have to enter 40 first and last names? Christ...
Let's say all names are entered and saved in a std::string array.
You need 2 things. A variable of type integer that counts to 15. And a for-loop that runs 40 times. Inside the loop you have an if statement which checks if counter == 15. If it is, then let the user press a thing and restart the counter back to 0.
So I could start it like this? Also I am like worst than a beginner. but when you said an integer that counts to 15 I am not sure how to do that would I have to declare a separate variable and then make a function?
I think I have to use #include <fstream> as well but just for the user to input and for me to extract the file.
and one more thing, sorry for asking so many questions, but would I need a cin of the names that the person could type in?
Im kinda confused now, and I think you are too. Because you mentioned the user has to input the 40 names, now you're saying you have to use <fstream> which would suggest the names should be in a file and you have to read it in using File I/O
but when you said an integer that counts to 15 I am not sure how to do that would I have to declare a separate variable and then make a function?
int counter = 0; After reading in a name, you add 1 to it by doing counter++;
Once it reaches 15, you do the stuff with it.
Sorry, I get really confused, I wasn't sure if i had to use <fstream> I got that mixed up with something else, but I do know that the user has to input the names and then I take that list and show it to them 15 names at a time and it pauses after 15 names and they press enter to continue the list.
I would suggest you start with 6 names, and pause after 2 names. I would also suggest to start with, instead of a user entering them, because that would take forever since you'll have to re-run the code plenty of times to fix errors and stuff, to just predefine them in an array.