Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/125.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 文件处理C++;_C++_File Handling - Fatal编程技术网

C++ 文件处理C++;

C++ 文件处理C++;,c++,file-handling,C++,File Handling,我正在创建iventory管理系统,但实际情况是 我输入的数据不会进入文件,也不会编译。我想知道是什么 我的代码完全错了 我之所以加上缺席的日期是为了从基本工资中扣除。提前谢谢。 这是我的节目 void input() { ofstream empfile; empfile.open("emp.txt",ios :: app); cout << "Enter the National Identity Card Number of the Employer \n

我正在创建iventory管理系统,但实际情况是 我输入的数据不会进入文件,也不会编译。我想知道是什么 我的代码完全错了

我之所以加上缺席的日期是为了从基本工资中扣除。提前谢谢。 这是我的节目

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


}
void输入()
{ 
流文件;
打开(“emp.txt”,ios::app);
cout>nic;
cout>名字;
库特姓氏;
cout>dob;
不能呼吸;
cout地址;
cout=3)
{
工资=工资-3000;
}
其他的
{
cout>nic>'>'>'>'>'>'>'>'>'>'>>'>'>'>'>'>>'>>地址>>'>'>'>>'>>'>>工资>>>>'>>结束;
empfile.close();
}

只需简单地将箭头指向另一侧,这就是为什么数据不会到达另一侧
empfile
对象

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

empfile这不会给你一个编译错误吗?是的,这就是问题所在。我很好奇为什么你决定在你的问题中声明一些其他症状。