473,473 Members | 2,155 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

pushing data from file to a vector

33 New Member
Hello,

I'm reading from a file strings that I'm pushing into a vector of strings. Is there any way to reduce this to one line:

Expand|Select|Wrap|Line Numbers
  1. .
  2.                 fileInput >> temp;
  3.                 vecFileContent.push_back(temp);
  4.  
provided these declarations

Expand|Select|Wrap|Line Numbers
  1. .
  2.                 std::ifstream fileInput;
  3.                 vector<string> vecFileContent;
  4.  
I tried a couple of curiosities, like vecFileContent.push_back(fileInput.operator>>), without success.

Thanks,

Ras.
Jun 15 '07 #1
1 1173
weaknessforcats
9,208 Recognized Expert Moderator Expert
Nope.


fileInput >> temp returns an ifstream& and vecFileContent.push_back() needs a string argument.
Jun 15 '07 #2

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

Similar topics

4
by: hall | last post by:
Hi. I have some problems with a class i've written that allocates memory dynamicaly. I want to put these objects into a std::vector, but it does not work. My class looks (simplified) like this: ...
3
by: dsa89 | last post by:
I would like to know if anyone can help me with this. I would like to load a file into a data structure but dont know how. Here is an example file. ;File Example ;Created 03/04/99 name =...
8
by: Darsant | last post by:
I'm currently reading 1-n number of binary files, each with 3 different arrays of floats containing about 10,000 values a piece for a total of about 30,000 values per file. I'm looking for a way...
7
by: fakeprogress | last post by:
For a homework assignment in my Data Structures/C++ class, I have to create the interface and implementation for a class called Book, create objects within the class, and process transactions that...
4
by: utab | last post by:
Dear all, I am reading a file line by line and change some fields, I am reading the data in to a vector <string> data_; say:
4
by: alacrite | last post by:
I have a class that I want to turn its contents into csv file. I want to be able to set the value of the delimiter, the name of the file it gets saved to, the path of that file, and maybe a few...
4
by: bcomeara | last post by:
I am writing a program which needs to include a large amount of data. Basically, the data are p values for different possible outcomes from trials with different number of observations (the p...
10
by: arnaudk | last post by:
Hello, I am relatively new to C++ and have been milling over a container related problem for a while now. I have a ~2Gb ASCII file of time-ordered data with 4 comma-separated columns. The first...
1
by: csgirlie | last post by:
I'm trying to store or arrange three sets of two-dimensional data into three 2xN matrices that are stored as NumPy arrays. import os # for file handling functions import numpy as...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.