| | |
C++ Extracting data from text files
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
A vector is a dynamic array. You can use the push_back() method to add an element to the end of the vector, and you can use the overloaded [] operator to access elements. That's just a quick overview though, see the link for more detailed information.
Also, I regret making that comment a few posts above. I think it would be much easier to put the member data into two separate files, one for full and one for young. I hadn't thought of that when I made the post.
Also, I regret making that comment a few posts above. I think it would be much easier to put the member data into two separate files, one for full and one for young. I hadn't thought of that when I made the post.
I'm a student. If my statements seem too absolute, feel free to coat them with "In my opinion..." or "I believe...".
•
•
Join Date: Aug 2008
Posts: 11
Reputation:
Solved Threads: 0
One thing I do not understand is what is an element, is it the whole line from the txt file or is just a piece of data from it, say the accNum? I just cannot seem to be able to grasp who vectors work, and the link seems to confuse me further, as all of the varibles are integers as my I have a c few types of varibles in my program.
My task asks me to use STL vector of pointers to Members (customers) to represent the scheme
My task asks me to use STL vector of pointers to Members (customers) to represent the scheme
Last edited by davidleeis14; Aug 5th, 2008 at 11:35 am.
vector as coolgamer mentioned above is a dynamic array. you can use it to store data.It can grow as per requirement and you dont need to worry about the size at compile time. it's best suited for conditions where you need random search and less of inserts and updates.
example:
when i declare a vector i mention the type of elements it will store, in this case 'int'. then i can insert as many 'int's' into it as needed. if your task requires you to use a vector of Member Pointers then you should declare something like
and then get pointers to member objects and insert into it.
each value stored in a vector is an element of the vector. its upto you to decide what will be the element in your program.
example:
c++ Syntax (Toggle Plain Text)
vector<int> v; int i =10; v.push_back(i); //fetch an element cout << v[0] << endl;
when i declare a vector i mention the type of elements it will store, in this case 'int'. then i can insert as many 'int's' into it as needed. if your task requires you to use a vector of Member Pointers then you should declare something like
c++ Syntax (Toggle Plain Text)
vector<Member*> v;
and then get pointers to member objects and insert into it.
each value stored in a vector is an element of the vector. its upto you to decide what will be the element in your program.
thanks
-chandra
-chandra
![]() |
Similar Threads
- adware.purityscan (Viruses, Spyware and other Nasties)
- Storing Text file in Database through VB (Visual Basic 4 / 5 / 6)
- spyware, pop-ups and more; amaena?? (Viruses, Spyware and other Nasties)
- adware.purityscan (Viruses, Spyware and other Nasties)
- very weird drive problems (Storage)
- urgent (C)
- Beginner needs assistance with 'error checking' program (C++)
Other Threads in the C++ Forum
- Previous Thread: plotting cpu and mem consumption
- Next Thread: HELP ME MY MISTAKE and HELP THE CORRECT The my homework
| Thread Tools | Search this Thread |
api array arrays based binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





