-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReporter.cpp
More file actions
68 lines (56 loc) · 1.79 KB
/
Reporter.cpp
File metadata and controls
68 lines (56 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
struct employee
{
int num; // èäåíòèôèêàöèîííûé íîìåð ñîòðóäíèêà
char name[10]; // èìÿ ñîòðóäíèêà
double hours; // êîëè÷åñòâî îòðàáîòàííûõ ÷àñîâ
};
int main()
{
/*
std::ifstream binaryFile("input.bin", std::ios::binary);
if (!binaryFile) {
std::cerr << "Failed to open the binary file." << std::endl;
return 1;
}
// Open the text file for writing
std::ofstream textFile("output.txt");
if (!textFile) {
std::cerr << "Failed to open the text file." << std::endl;
return 1;
}
// Read data from the binary file and transfer it to the text file
char byte;
while (binaryFile.read(&byte, sizeof(byte))) {
// Convert the binary data into a text representation
std::string text = std::to_string(byte);
// Write the converted text data into the text file
textFile << text << " ";
}
*/
double Salary;
string BinFile, Report;
cout << "Binary file name, report path and salary per hour: \n";
getline(cin, BinFile);
getline(cin, Report);
cin >> Salary;
ofstream repout(Report); //
repout << "Îò÷¸ò ïî ôàéëó " << BinFile << endl;
ifstream readbin(BinFile, ios::binary); // ÷òåíèå áèíàðíîãî
if (!readbin) {
cout << "Cannot open file!" << endl;
return 1;
}
//int NumberOfEmployees = readbin.tellg() / sizeof(employee);
//readbin.seekg(ios::beg);
employee temp;
while (readbin.read((char*)&temp, sizeof(employee)))
{
repout << temp.num << " " << temp.name << " " << temp.hours << " " << temp.hours * Salary << endl;
}
readbin.close();
repout.close();
}