Question: I need a C + + programming code to do the following. - Open the input file called log.txt read it and store the
I need a C programming code to do the following.
Open the input file called "log.txt read it and store the data in a doubly linked list created dynamicallylogpdf file format
Sort the information by IP to perform the searches BE CAREFUL with two and three digit numbers, numeric order not alphabetical
If there are two or more accesses from the same IP address, the second sorting criterion is the date and time of access.
In case there is another tie, the third criterion is the error message.
Ask the user for the start and end IPs of the information search. the input is like a string, first one, and then another
Display the records corresponding to those IPs, in the standard output, in descending order, by IP second criterion is the date and time, first those of Dec, Nov, Oct, Sept
Store the result of sorting in ascending order by IP in a file called SortedData.txt second criterion is the date June, July, August, Sept, Oct, same sorting criteria.
Example of input:
I already have my log file, and I have worked on this code
#include
#include
#include
#include
using namespace std;
int convmesconst string& mes
if mes "Jan"
return ;
if mes "Feb"
return ;
if mes "Mar"
return ;
if mes "Apr"
return ;
if mes "May"
return ;
if mes "Jun"
return ;
if mes "Jul"
return ;
if mes "Aug"
return ;
if mes "Sep"
return ;
if mes "Oct"
return ;
if mes "Nov"
return ;
if mes "Dec"
return ;
return ;
class Mes
public:
string mes;
Messtring mes : mesmes
int convmes const
return :: convmesmes;
;
class Dia
public:
int dia;
Diaint dia : diadia
;
class Hora
public:
string hora;
Horastring hora : horahora
;
class Ip
public:
string ip;
Ipstring ip : ipip
;
class Mensaje
public:
string mensaje;
Mensajestring mensaje : mensajemensaje
;
class Datos
public:
Mes mes;
Dia dia;
Hora hora;
Ip ip;
Mensaje mensaje;
Datosstring mes, int dia, string hora, string ip string mensaje
: mesmes diadia horahora ipip mensajemensaje
;
struct Node
Datos data;
Node prev;
Node next;
NodeDatos data : datadata
;
void insertaNode pth Node ptt Datos dat
Node neww new Nodedat;
newwdata dat;
if pth nullptr
pth neww;
ptt neww;
else
newwprev ptt;
pttnext neww;
ptt neww;
void imprime Node ptt
for Node poi ptt; poi nullptr; poi poiprev
cout poidata.mes.mes poidata.dia.dia poidata.hora.hora poidata.ipip poidata.mensaje.mensaje endl;
int main
ifstream file;
file.openbitacoratxt;
if file.isopen
cout "Error al abrir el archivo." endl;
return ;
else
string line;
Node head nullptr;
Node tail nullptr;
while getlinefile line
stringstream ssline;
string mes;
string hora;
string ip;
string mensaje;
int dia;
ss mes dia hora ip;
getliness mensaje;
mensaje mensaje.substr;
inserta&head, &tail, Datosmes dia, hora, ip mensaje;
imprimetail;
file.close;
Help me complete what I need to do to comply with what is indicated
NOTE: VECTORS SHOULD NOT BE USED
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
