我正在尝试将cout命令转换为c ++中的getline命令.
这是我试图改变的代码....
for (int count=0; count < numberOfEmployees; count++)
{
cout << "Name: ";
cin >> employees[count].name;
cout << "Title: ";
cin >> employees[count].title;
cout << "SSNum: ";
cin >> employees[count].SSNum;
cout << "Salary: ";
cin >> employees[count].Salary;
cout << "Withholding Exemptions: ";
cin >> employees[count].Withholding_Exemptions;
}
Run Code Online (Sandbox Code Playgroud)
我正试图改变这一行:cin >> employees[count].name;这一行:cin >> employees[count].title;进入getlines.有人可以帮忙吗?
谢谢
我正试图制作一张这样的桌子......(只是没有用来分隔每个项目的点)
每周工资表:
名称.....................标题....... ......总税收......网
Ebenezer Scrooge合伙人250.00 ..62.25 .187.75
Bob Cratchit ..........职员...... 15.00 .... 2.00 ..13.00
这是我的代码看起来像这部分....
for (int count=0; count < numberOfEmployees; count++)
{
cout << "Employee: \n";
cout << "\t Name: ";
cin.getline (employees[count].name, EMPLOYEESIZE);
cout << "\t Title: ";
cin.getline (employees[count].title, EMPLOYEESIZE);
cout << "\t SSNum: ";
cin >> employees[count].SSNum;
cout << "\t Salary: ";
cin >> employees[count].Salary;
cout << "\t Withholding Exemptions: ";
cin >> employees[count].Withholding_Exemptions;
cin.ignore();
cout << "\n";
}
double gross;
double tax;
double net; …Run Code Online (Sandbox Code Playgroud)