I've writen this code. But the first getline() only acts only one time when i=0.
For the second time it doesn't act. Do you know why?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;
void main()
{
string name,surname;
int salary,i=0;
for(i=0;i<2;i++)
{
cout<<"Enter name: ";
getline(cin,name);
cout<<"Enter surname: ";
getline(cin,surname);
cout<<"Enter salary per month: ";
cin>>salary;
}
}
|
Output:
Enter name: david
Enter surname: alen
Enter salary per month: 10
Enter name: Enter surname:
Last edited on
Thank you codewalker.
It is solved.