-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
38 lines (32 loc) · 1.03 KB
/
main.cpp
File metadata and controls
38 lines (32 loc) · 1.03 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
#include <iostream>
#include <fstream>
#include "libs/PacketParser.h"
int main()
{
std::ifstream inputFile;
std::ofstream outputFile("io/output_packets");
std::string line;
PacketParser parser;
inputFile.open("io/input_packets", std::ios::in);
// Condition to check if the file was opened successfully
if (inputFile.is_open())
{
int lineCount = 0;
// Read each line in the file and parse it.
while (getline(inputFile, line))
{
outputFile << "Packet # " << ++lineCount << ":" << std::endl;
outputFile << line << std::endl; // write whole packet
outputFile << parser.ParsePacket(line) << std::endl; // Parse the input line and append the formatted data to the output file
outputFile << std::string(30, '*') << "\n \n";
}
// Close the file when done
inputFile.close();
outputFile.close();
}
else
{
std::cout << "File didn't open successfully" << std::endl;
}
return 0;
}