2015-12-02 99 views
-1

我正在创建iventory管理系统,但会发生什么是 我输入的数据不会进入文件,也不会编译。我想知道什么 与我的代码完全错误。文件处理C++

之所以我补充说缺席的日期数是从基本薪水中扣除它。提前感谢。 这是我的计划

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(); 


} 
+0

这不会给你一个编译错误? –

+0

是的,这就是问题 – YoLa

+0

我很好奇你为什么决定在你的问题中声称一些其他症状。 –

回答

0

你有什么只是简单地把箭头对方,这就是为什么数据不会去到 empfile对象

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