Cin Problem../quesiton

Program asks how many people contributed to a company.

The user has to input the names and money.

What I wanted to do was to make it so that I can input name and THEN the Money.

Right now it does the reverse, it asks for the amount of money contributed and then the name.

I've had some problems with input and a tough time understanding how cin.get,
cin.getline truly work.

If you can give me a step by step explanation of how pretty much they work, and the best possible method to get name inputted first and then the input money.

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
33
34
35
36
37
38
39
40
  #include <iostream>
#include <string>

using namespace std;




struct Society
    {

        string name;
        double contribution;

    };

int main()
 {

int size;
cout<<"Type the number of contributers: ";
cin>>size;
Society *contributee = new Society[size];
for(int i = 0;i<size;i++)
{

    cout<<"Enter the contribution: ";
    cin>>contributee[i].contribution;
    cin.get();

cout<<"Enter the name of the contributor: ";
    getline(cin,contributee[i].name);
}

}




Oh.....! Thank you so much!
Topic archived. No new replies allowed.