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.
#include <iostream>
#include <string>
usingnamespace 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);
}
}