<分区>
我想将字符串输入此 C++ 程序,但以下代码不起作用。它不会将员工的姓名作为输入。它只是跳过。对不起,我是 C++ 的新手。
#include<iostream>
#include<string>
using namespace std;
int main()
{
int empid;
char name[50];
float sal;
cout<<"Enter the employee Id\n";
cin>>empid;
cout<<"Enter the Employee's name\n";
cin.getline(name,50);
cout<<"Enter the salary\n";
cin>>sal;
cout<<"Employee Details:"<<endl;
cout<<"ID : "<<empid<<endl;
cout<<"Name : "<<name<<endl;
cout<<"Salary : "<<sal;
return 0;
}