文件处理 C++

File handling C++

我正在创建库存管理系统,但结果是 我输入的数据不会进入文件并且 compile.I 不想知道什么 我的代码完全错误。

我之所以加上缺日期数是为了提前从基础Salary.Thanks中扣除。 这是我的程序

void input()
{ 
    ofstream empfile;
   empfile.open("emp.txt",ios :: app);
   cout << "Enter the National Identity Card Number of the Employer \n";
   cin >>nic;
   cout << "Enter the first name of the Employer \n";
   cin >>firstName;
   cout <<"Enter the last name of the Employer \n";
   cin >>lastName;
   cout << "Enter the date of birth [date/month/year] \n";
   cin >> dob;
   cout <<"Enter your Telephone Number \n";
   cin>> pnum;
   cout <<"Enter your address \n";
   cin >> address;
   cout <<"Your daily basic Salary is Rs20000 \n";
   cout << "How many days did she/he haven't reported to the Factory? \n";
   cin >>days;

    if(days=1)
    {
      salary=salary-1000;
    }
    else if(days<3 && days>1)
    {
        salary=salary+2000;
    }
    else if(days>=3)
    {
       salary=salary-3000;
    }
    else
    {
        cout << "Please enter a valid number of days \n";
    }
   empfile >> nic >> ' ' >>firstName >> ' ' >> lastName >> ' ' >> dob >> ' ' >>pnum>> ' ' >>address >> ' ' >> salary>> endl;
   empfile.close();


}

你所要做的只是简单地将箭头转到另一边,这就是为什么数据不会转到 empfile 对象

 empfile << nic << ' ' <<firstName << ' '<< lastName << ' '<< dob << ' '<<pnum<<' '<<address <<' '<<salary<< endl;
   empfile.close();