473,406 Members | 2,293 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,406 software developers and data experts.

Using Vectors vs. Arrays

Hello,

I have a file that I am reading date from.

File format is as follows:

a 556644f3
b 44545351
......

I want to read the entire contents of this file into a 2-D array or
vector.

I'd like to use vectors because it easily allows me to do what I need
to with this data.

My question is there are a lot of these data entries in this file and I
don't know how many.

I want to dynamically create this array or vector with this data with
the row being 1 data entrie and the columns being the number of entries
there are.

How do I do this using vectors?

Sep 25 '06 #1
2 1640
"ucfcpegirl06" <tr**************@gmail.comwrote:
Hello,

I have a file that I am reading date from.

File format is as follows:

a 556644f3
b 44545351
.....

I want to read the entire contents of this file into a 2-D array or
vector.

I'd like to use vectors because it easily allows me to do what I need
to with this data.

My question is there are a lot of these data entries in this file and I
don't know how many.

I want to dynamically create this array or vector with this data with
the row being 1 data entrie and the columns being the number of entries
there are.

How do I do this using vectors?
Wrap a vector into a 2D array class. There is a start of one on the FAQ:
http://www.parashift.com/c++-faq-lit...html#faq-13.10

--
There are two things that simply cannot be doubted, logic and perception.
Doubt those, and you no longer*have anyone to discuss your doubts with,
nor any ability to discuss them.
Sep 25 '06 #2
In article <11*********************@e3g2000cwe.googlegroups.c om>,
tr**************@gmail.com says...
Hello,

I have a file that I am reading date from.

File format is as follows:

a 556644f3
b 44545351
.....

I want to read the entire contents of this file into a 2-D array or
vector.
class line {
char a;
int b;
};

std::vector<linelines;

std::ifstream infile("file");

std::istream_iterator<linedata(infile), end;

std::copy(data, end, std::back_inserter(lines));

--
Later,
Jerry.

The universe is a figment of its own imagination.
Sep 27 '06 #3

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

Similar topics

10
by: Michael Aramini | last post by:
I need to represent 1D and 2D arrays of numeric or bool types in a C++ program. The sizes of the arrays in my intended application are dynamic in the sense that they are not known at compile time,...
12
by: Dave Theese | last post by:
Hello all, I'm in a poition of trying to justify use of the STL from a performance perspective. As a starting point, can anyone cite any benchmarks comparing vectors to plain old...
25
by: rokia | last post by:
in a project, I use many,many stl such as stack,list,vctor etc. somewhere the vector's size is more than 2K. is this a efficient way?
10
by: spoc | last post by:
I have been using memcpy to copy one class to another of the same type. There are reasons why I had to do this bug am getting some odd crashes and maybe I'm doing something dodgy copying classes...
5
by: Computer Whizz | last post by:
I was reading through Accelerated C++ at work when I read through the first mention of Vectors, giving us certain functions etc. Is there any benefit of Arrays over Vectors? Since all Vectors...
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...
3
by: John Bend | last post by:
Hello. Can anyone please suggest some good tutorial links where Java Vectors and Arrays are explained and compared? I'm a proficient programmer but fairly new to Java. Whilst I understand...
7
by: Mack | last post by:
Hi Guys, In C++ , i was just wondering what is the advantage of Vectors over arrays? I saw one sample program doing pretty much same way traditional vectors do then what the use of VECTORS??or...
10
by: pra1983 | last post by:
Can any one tell me how to use vectors insteard of two dimensional arrays... I was trying to store some thousands of values in an aray but i gives me error in between saying that " Stack is out...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.