Looping with a string?

I'm trying to get a string and a number to write to a file number of times, which the user determines. But the loop only partially runs before closing.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <fstream>
#include <string>

using namespace std;
int main()
{
    string companyName;    
    int numberOfPeople, chargePerPerson;
    int timesToRun, count;
        
    ofstream Seminar("Seminar.dat");
    
    cin >> timesToRun;
    for(count = 0; count < timesToRun;count++)
    {
    cout << "Enter the company name: ";
	getline(cin, companyName);
	cin.get();
    
    cout << "\nEnter the number of people attending: ";
    cin >> numberOfPeople;
    cin.get();
	
	Seminar << companyName << "~" << numberOfPeople << endl;
    }
    
    Seminar.close();
	
	system("PAUSE");
	return 0;
}

3
Enter the company name: blahblah blah

Enter the number of people attending: Enter the company name:
Enter the number of people attending: Enter the company name:
Enter the number of people attending: Press any key to continue . . .
try replacing the cin.get() on line 19 and 23 with cin.sync()
works. Thank you!
Topic archived. No new replies allowed.