Re: Reading a file from a specified range
From: mkarja (mmmc_reptail_at_hotmail.com)
Date: 10/27/04
- Next message: Ioannis Vranos: "Re: conversion of string to all lower case"
- Previous message: Catalin Pitis: "Re: Your C++ Homework"
- In reply to: Chris \( Val \): "Re: Reading a file from a specified range"
- Next in thread: David Rubin: "Re: Reading a file from a specified range"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 27 Oct 2004 06:08:03 -0700
> "Chris \( Val \)" <chrisval@bigpond.com.au> wrote in message >
> news:<2u6eofF26st2gU1@uni-berlin.de>...
>
> You know, programmers are supposed to actually program :-)
>
Heh, yeah so I've heard. I don't know where that idea is from :)
Actually I did some programming on my own (gasp) and I managed
to solve my problem. I was perhaps a bit hasty on asking for
help, but I was in a hurry to get it done. Deadline tomorrow.
Here's how I did it if anyones interested. Not sure if it's the
best way to do this, but this is how I did it anyways.
============ code start =========================
std::ifstream infile( "logfile.txt" );
std::string commandResponse;
std::vector<std::string> commandResponse2;
std::string Buffer;
int i;
int j;
while( std::getline( infile, Buffer ) )
{
commandResponse2.push_back(Buffer);
if( Buffer.find( "/***" ) )
continue;
infile.seekg( 1, std::ios_base::cur );
std::getline( infile, Buffer );
break;
}
int respSize = commandResponse2.size();
for(i=respSize-1; i>0; i--) {
if ( commandResponse2.at(i).find( "<" ) != std::string::npos )
{
for(j=i; j<respSize; j++) {
commandResponse += commandResponse2.at(j);
}
break;
}
}
commandResponse += Buffer;
Buffer = "";
printf("\n Result2: \n %s \n", commandResponse.c_str());
infile.close();
============ code end =========================
============ logfile start =========================
< [command name]
LOADING PROGRAM
/*** SYNTAX ERROR ***/
/*** INVALID DELIMITER ***/
============ logfile end =========================
There's a snippet of the code and the part of the logfile that
matters. There's bunch of lines and text before and after what's
on this example snippet from the logfile.
The code above goes thru the logfile and searhes until it finds
the /*** bit and puts it in the vector. Then it gets the next
line and puts it in the Buffer.
Then it goes through the vector backwards from the last row in
the vector until it finds the < character and appends it all to
the string. Last it appends the contents of the Buffer string
to the string as well. Or something like that at least.
Thanks for you help and patience Chris. I propably wouldn't have
been able to do this on time without your help. So BIG thanks.
---- mkarja
- Next message: Ioannis Vranos: "Re: conversion of string to all lower case"
- Previous message: Catalin Pitis: "Re: Your C++ Homework"
- In reply to: Chris \( Val \): "Re: Reading a file from a specified range"
- Next in thread: David Rubin: "Re: Reading a file from a specified range"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|