F
fabrice
Hello,
I've got trouble reading a text file (event viewer dump) by using the
getline() function...
After 200 - 300 lines that are read correctly, it suddenly stops
reading the rest of the file...
Thank you to all of you who can help me with this one...
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
int main () {
int MAX_LENGTH = 10240*10240;
char buffer[1000];
char content[1000];
int result;
int newresult;
int newresult_bis;
int newresult2;
int getpart;
int check;
ifstream notes2 ("c://Data//Utility//Share//Auditing_notes_services//sec_dump.txt");
ofstream putdata("c://Data//Utility//Share//Auditing_notes_services//result_notes.txt",
ios::app);
// lire le fichier sec_dump.txt ligne par ligne - THIS IS THE DUMP
FILE WHERE THE PROGRAM STOPS READING IN THE MIDDLE
while( ! notes2.eof() ) {
char *content2;
content2 = new char[MAX_LENGTH];
notes2.getline (content2,MAX_LENGTH);
_strlwr(content2);
string input2 = content2;
newresult_bis = input2.find("nt authorit");
if(newresult_bis != string::npos) {
continue;
}
ifstream notes ("c://Data//Utility//Share//Auditing_notes_services//source_rep.txt");
// Lire les nom de fichier dans le repertoir ligne par ligne
while (! notes.eof() ) {
notes.getline (buffer,1000);
strcpy(content, buffer);
_strlwr(content);
string input = content;
result = input2.find(input);
newresult = input2.find("object");
string first = input2.substr(0, newresult);
newresult2 = input2.find("dom206");
string first2 = first.substr(newresult2, 14);
// check pour ne pas ecrire de doublons
if(result != string::npos) {
FILE * pFile;
long lSize;
char * buffer4;
pFile = fopen (
"c://Data//Utility//Share//Auditing_notes_services//result_notes.txt"
, "rb" );
if (pFile==NULL) exit (1);
// obtain file size.
fseek (pFile , 0 , SEEK_END);
lSize = ftell (pFile);
rewind (pFile);
// allocate memory to contain the whole file.
buffer4 = (char*) malloc (lSize);
if (buffer4 == NULL) exit (2);
// copy the file into the buffer.
fread (buffer4,1,lSize,pFile);
string temporary = buffer4;
/*** the whole file is loaded in the buffer. ***/
string whole = first2 + ";" + input;
check = temporary.find(whole);
if((check == -1) && (first2 != "dom206\\adminis")) {
putdata << first << input << endl;
}
}
}
}
}
I've got trouble reading a text file (event viewer dump) by using the
getline() function...
After 200 - 300 lines that are read correctly, it suddenly stops
reading the rest of the file...
Thank you to all of you who can help me with this one...
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
int main () {
int MAX_LENGTH = 10240*10240;
char buffer[1000];
char content[1000];
int result;
int newresult;
int newresult_bis;
int newresult2;
int getpart;
int check;
ifstream notes2 ("c://Data//Utility//Share//Auditing_notes_services//sec_dump.txt");
ofstream putdata("c://Data//Utility//Share//Auditing_notes_services//result_notes.txt",
ios::app);
// lire le fichier sec_dump.txt ligne par ligne - THIS IS THE DUMP
FILE WHERE THE PROGRAM STOPS READING IN THE MIDDLE
while( ! notes2.eof() ) {
char *content2;
content2 = new char[MAX_LENGTH];
notes2.getline (content2,MAX_LENGTH);
_strlwr(content2);
string input2 = content2;
newresult_bis = input2.find("nt authorit");
if(newresult_bis != string::npos) {
continue;
}
ifstream notes ("c://Data//Utility//Share//Auditing_notes_services//source_rep.txt");
// Lire les nom de fichier dans le repertoir ligne par ligne
while (! notes.eof() ) {
notes.getline (buffer,1000);
strcpy(content, buffer);
_strlwr(content);
string input = content;
result = input2.find(input);
newresult = input2.find("object");
string first = input2.substr(0, newresult);
newresult2 = input2.find("dom206");
string first2 = first.substr(newresult2, 14);
// check pour ne pas ecrire de doublons
if(result != string::npos) {
FILE * pFile;
long lSize;
char * buffer4;
pFile = fopen (
"c://Data//Utility//Share//Auditing_notes_services//result_notes.txt"
, "rb" );
if (pFile==NULL) exit (1);
// obtain file size.
fseek (pFile , 0 , SEEK_END);
lSize = ftell (pFile);
rewind (pFile);
// allocate memory to contain the whole file.
buffer4 = (char*) malloc (lSize);
if (buffer4 == NULL) exit (2);
// copy the file into the buffer.
fread (buffer4,1,lSize,pFile);
string temporary = buffer4;
/*** the whole file is loaded in the buffer. ***/
string whole = first2 + ";" + input;
check = temporary.find(whole);
if((check == -1) && (first2 != "dom206\\adminis")) {
putdata << first << input << endl;
}
}
}
}
}