1>c:\users\anthony\documents\visual studio 2005\projects\tests\tests\main.cpp(10) : error C2337: 'i' : attribute not found
Can you post the code please? I can't see any syntax errors in the code (certainly nothing resembling this), so perhaps you made some small mistake when copying it.
In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
... that's why you use a for loop instead of std::copy, and perhaps an "if" statement. You do have to do SOME work for yourself you know...
No offense intended but: A big part of programming is problem solving. That means taking a problem, dissecting it into its various components, and then figuring out how to build a solution based on what you have. If you don't know what to do, the best thing to do is to learn (aka, research, spend time reading, etc). From what I've seen here, you've basically copied and pasted what's been posted, instead of LEARNING what the code that's been posted does. You will never learn anything if you don't start trying to solve the problem yourself. Generally you will never be given the entire solution to a problem, instead people will give you bits and pieces, and your job is to figure out how to take the knowledge you've learned (from those bits and pieces) and put them together or alter them to provide a solution to your problem.
In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
Quote:Original post by Washu ... that's why you use a for loop instead of std::copy, and perhaps an "if" statement. You do have to do SOME work for yourself you know...
No offense intended but: A big part of programming is problem solving. That means taking a problem, dissecting it into its various components, and then figuring out how to build a solution based on what you have. If you don't know what to do, the best thing to do is to learn (aka, research, spend time reading, etc). From what I've seen here, you've basically copied and pasted what's been posted, instead of LEARNING what the code that's been posted does. You will never learn anything if you don't start trying to solve the problem yourself. Generally you will never be given the entire solution to a problem, instead people will give you bits and pieces, and your job is to figure out how to take the knowledge you've learned (from those bits and pieces) and put them together or alter them to provide a solution to your problem.
Yes I do understand that
#include <iostream>#include <fstream>#include <string>#include <vector>using namespace std;vector<string> readAllLines(string const& filename) { vector<string> lines; ifstream ifs(filename.c_str()); while (ifs) { string line; getline(ifs, line); if (ifs) lines.push_back(line); } return lines;}int main() { vector<string> lines = readAllLines("text.txt"); int i = lines.size(); cout << i << endl;}
I managed to get it to tell me the size of the vector, nothing more. I will lone it from here, close this thread if need be
Quote:Original post by Powell I managed to get it to tell me the size of the vector, nothing more. I will lone it from here, close this thread if need be
*sigh* Now you sound like a petulant child.
You know the size of the vector, now perhaps you should lookup "How do I iterate (or loop) over a vector" in whatever reference material you have.
In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.