473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Need help with stl vectors (?)

Tom
How do you get the whole line and put it in a vector from a txt file,
I would like to first get a line, store it to the first element in a
vector and then keep on doing this until the end of the file is
reached. I would appreciate it if anyone helped me.
Jul 22 '05 #1
1 1002

"Tom" <sn***@hotmail.com> wrote in message
news:78**************************@posting.google.c om...
How do you get the whole line and put it in a vector from a txt file,
I would like to first get a line, store it to the first element in a
vector and then keep on doing this until the end of the file is
reached. I would appreciate it if anyone helped me.


#include <fstream>
#include <string>
#include <vector>

using namespace std;

ifstream Input( "somefile.txt" );
string Line;
vector<string> Txt;

while( getline( Input, Line ) )
{
Txt.push_back( Line );
}
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Amit | last post by:
Hello. I am having some problem organizing a set of vectors. The vectors itself, could contain a pointer( say integer pointer) or could contain another object MyClass. 1>So, first of all, is...
5
by: madhu | last post by:
http://msdn2.microsoft.com/en-us/library/fs5a18ce(VS.80).aspx vector <intv1; v1.push_back( 10 ); //adds 10 to the tail v1.push_back( 20 ); //adds 20 to the tail cout << "The size of v1 is " <<...
1
by: Rob | last post by:
How would I do this? I want to be able to handle vectors of many different types of data and vectors that can contain any number of other vectors of data. Currently, I have a templated...
0
by: Peter Duniho | last post by:
On Thu, 01 May 2008 07:01:00 -0700, MrNobody <MrNobody@discussions.microsoft.comwrote: It would help if you could be more specific about how you're currently mapping mouse coordinates to...
4
by: CFFAN | last post by:
<form action="" method="post" enctype="multipart/form-data"> <input type="file" name="img"> <input type="submit" name="submit" value="submit"> </form> <cfif ISDefined('Form.img')> <cffile...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.