By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,570 Members | 1,251 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,570 IT Pros & Developers. It's quick & easy.

any hints would help

P: 3
Expand|Select|Wrap|Line Numbers
  1.  vector<Log_Entry> parse(string);

This function should do the following:

* Open a log file specified by the parameter name (File I/O).
* Read lines from the opened file.
* Create a Log_Entry object passing the line just input.
* Push each List_Entry object onto a vector.
* Return the vector of Log_Entrys.

so far I have got

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <fstream>
  5. #include "log_view.h"
  6.  
  7. int main();
  8.  
  9.  
  10. std::vector<Log_Entry> parse(string file)
  11. {
  12.  
  13. }
Sep 19 '07 #1
Share this Question
Share on Google+
3 Replies


Expert 100+
P: 464
first i recommend doing some research on file I/O. There is an article in the articles section on this website. There are also TONS of examples from your favorite c++ resource. I then would define your log file structure and attempt your homework assignment. Then if you encounter errors or problems come back and post them and we will be more than willing to help.
Sep 19 '07 #2

P: 3
first i recommend doing some research on file I/O. There is an article in the articles section on this website. There are also TONS of examples from your favorite c++ resource. I then would define your log file structure and attempt your homework assignment. Then if you encounter errors or problems come back and post them and we will be more than willing to help.
I really appreciate this after reading some thing about file I/O, I have gotten to this point but I got errors after defining the structure.

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <fstream>
  5. #include "log_view.h"
  6.  
  7. int main();
  8.  
  9. std::vector<string> split (const string&, char)
  10. {}
  11. std::vector<Log_Entry> parse(string file)
  12. {
  13.   string in_file_name("log_small.txt");
  14.   std::ifstream in(in_file_name.c_str());
  15.  
  16.  
  17. }
Sep 19 '07 #3

weaknessforcats
Expert Mod 5K+
P: 9,197
[quote=sromano]
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include "log_view.h"

int main(); <<<<<<<<<!!!!!!!!!

std::vector<string> split (const string&, char)
{}
std::vector<Log_Entry> parse(string file)
{
string in_file_name("log_small.txt");
std::ifstream in(in_file_name.c_str());


}
[/code]

main() does not have a body!

Also, your functions shoukd return references to a vector rather than a vector. Otherwise, to do the return a copy of the entire vector will need ot be made just to do the return.

A better solution is to return void and pass your vector tio the functions by reference.
Sep 22 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.