File Input Question

I'm writing a program that inputs web logs from a file. I need though to split each part of the log into it's separate parts. What I can't remember is how to set which character to stop inputting for.

The default as you know is white space (I.E. each time a white space is reached in the file, it stops the stream into that variable and goes to the next variable, in my case the different variables of a struct.)

How do I change what that is. Like when I reach a ] in the file, it stops the input?

I hope that made sense.

EDIT - Also, I need it to look for different characters for the same run-through. How do I change it mid-way?
[684 byte] By [Chrispy] at [2007-11-20 10:55:05]
# 1 Re: File Input Question
You can use:

inputFile.get(variable, stream size, delimiter);

And set the delimiter to whatever you want it to stop reading at, then use that method to read the data into individual variables.
RaleTheBlade at 2007-11-9 1:24:41 >
# 2 Re: File Input Question
I'll try that.

What, though, is the stream size?

EDIT - Also, do I put the delimiter in quotes? And it I wanted it to be white space, would I leave it empty or put " "?
Chrispy at 2007-11-9 1:25:46 >
# 3 Re: File Input Question
Sorry for the double post, but I didn't think it would be noticed if I didn't do this.

Here is the struct:

struct Logs
{
std::string IP_Address;
std::string More_Information;
std::string User_Information;
std::string Day_Time_Zone;
std::string Requested_Path;
int Status_Code;
double Bytes;
std::string Referral_URL;
std::string User_Agent;
};

Here is the function that inputs into the vector of this struct:

while (/*!In_File.eof()*/ a != 1)
{
Logs Inputted_Log;

In_File.get(Inputted_Log.IP_Address, 25);
In_File.get(Inputted_Log.More_Information, 25);
In_File.get(Inputted_Log.User_Information, 25);
In_File.get(Inputted_Log.Day_Time_Zone, 25, ' ] ');
In_File.get(Inputted_Log.Requested_Path, 25, ' " ');

In_File >> Inputted_Log.Status_Code;
In_File >> Inputted_Log.Bytes;

In_File.get(Inputted_Log.Referral_URL, 25, ' " ');
In_File.get(Inputted_Log.User_Agent, 25, ' " ');

Log_Vector.push_back(Inputted_Log);
a = 1;
}

and it's giving me this error for each .get line:

Error - o matching function for call to `std::basic_fstream<char, std::char_traits<char> >::get(std::string&, int)'
note - candidates are: typename std::basic_istream<_CharT, _Traits>::int_type std::basic_istream<_CharT, _Traits>::get() [with _CharT = char, _Traits = std::char_traits<char>]
With a few more notes after that for other candidates.

I have no idea what to do with that.

Also, I have .EOF in that while loop, but it wasn't working. When I had it as not EOF it was an infinite loop, when it was EOF it didn't even go into the while loop. Any suggestions?
Chrispy at 2007-11-9 1:26:45 >
# 4 Re: File Input Question
Hello

I have a completely different problem, but also linked with fstream. My VC++EE05 does make fstream::read() and fstream::getline() functions unworkable!

Its incredible, because i used to have no problem w/ using them once, now they started acting weird...

Can someone help?
piotroxp at 2007-11-9 1:27:53 >
# 5 Re: File Input Question
I'm writing a program that inputs web logs from a file. I need though to split each part of the log into it's separate parts.
Use PERL for that, not C++! ;) What I can't remember is how to set which character to stop inputting for. If you are reading into a string, using operator<<, you cannot set the delimitor. Either you read in the whole line and then use boost::regexp to separate it into parts (it is what I recommend doing), or you use ifstream::get function as RaleTheBlade recommended.
it's giving me this error for each .get line:Check the syntax: The first argument of get is a char*, not std::string. So you have to allocate a buffer big enough to hold the read in data. Also the last argument is a single char, not a string. What you put there (a string in single quotes) is not defined.
treuss at 2007-11-9 1:28:49 >