I'm having a problem while trying to loop with the getline function. The program compiles but after being prompted for number of repetitions, it displays:
Name: Month:
when it should display
Name:
Month:
I've tried looking around in the forums and on Google but I'm not getting any help out of them.
EDIT: Nvm, it's not related to end line. When you use cin the enter key is still in the input buffer and the first getline is taking it in. You need to flush the buffer before getting input.
I know that the program stops to wait for input, but my problem is that it won't let me input a string. It skips the 'name' completely and asks for a 'month'.
Anywhere I've tried to put cin.sync() or fflush(stdin) it wouldn't work. the program will compile but It won't run the way I want it to or it will output the wrong data.
Now that I've compiled your code and see what you're trying to do, we should address the first issue in that you don't have an vector to actually store all of the birthdays you're user asks for.
Well the only things I'm supposed to be working with in this is file I/O. We haven't learned vectors yet. I have a text file saved in the same directory so the birthdays will be saved to that.
You're entering an integer when you're asked for the month right? I compiled your app without paying much attention and it kept warping through because I was typing out the name of the month.
EDIT: I also added "cin.sync();" after every input just to be sure.
My problem to begin with was when trying to input the name, getline would not be recognized by the loop. (Refer back to my original post). I fixed that problem but now the problem is that in the output file, only the last names are copied. After I put a ' ' character in the array, it disregards anything written before it.