文件处理C++
File handling C++
我正在创建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();
}
您只需将箭头转到另一侧,这就是为什么数据不会转到empfile
对象
empfile << nic << ' ' <<firstName << ' '<< lastName << ' '<< dob << ' '<<pnum<<' '<<address <<' '<<salary<< endl;
empfile.close();
相关文章:
- 警告处理为错误这里有什么问题
- 在C#中处理C++指针而不使用unsafe的最佳方法
- 处理多个异常集合的C++方法
- 找不到成员对象:没有名为get_event()的成员,也处理多态性和向量
- 使用流处理接收到的数据
- 获取日期异步信号安全吗?如果在信号处理程序中使用,它会导致死锁吗
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 基于多个条件处理地图中的所有元素
- 如何用数字处理log(0)
- SSL上的`curl_easy_send`和`curl_asy_recv`:如何处理`CURLE_AGAIN`
- 错误处理.将系统错误代码映射到泛型
- 从文本文件中读取时钟时间和事件时间并进行处理
- 在运行时处理类型擦除的数据-如何不重新发明轮子
- 在for循环中使用auto vs decltype(vec.size())来处理字符串的向量
- 用于矢量处理的多个线程
- 对字符串进行排序时,在c++中处理sort()
- 如何处理linux终端中带有负号(-)的C++中的命令行参数
- 处理除以零会导致<csignal>意外行为
- 是否可以在c++中处理字符串流中的各个元素
- 在多个核心中处理一个HTTP请求