how to parse log files using structures or enum

Recommended Answers

You don't. You parse a file by reading it and breaking the line read into fields. Then you can store it in your structure.

Jump to Post

It depends on how the log file was written. If it is in binary mode and written with fwrite() then you can use fread() to read each record directly into the structure. Otherwise if its text mode and written with fprintf() then use fgets() to read it and pars the …

Jump to Post

All 5 Replies

You don't. You parse a file by reading it and breaking the line read into fields. Then you can store it in your structure.

It depends on how the log file was written. If it is in binary mode and written with fwrite() then you can use fread() to read each record directly into the structure. Otherwise if its text mode and written with fprintf() then use fgets() to read it and pars the line into individual fields, then populate with structure members with that information.

post some example of log file, and what do you expect of it

i have a log file with the line for ex:
08:32:00 : .NET install #2 is : v2.0.50727
i need to parse this using structures

post the structure

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.