Solved

Reading ile and parsing

Posted on 2003-11-29
1
175 Views
Last Modified: 2010-04-02
I am trying to read the file below and store to array.
Each number is between 1 – 80 and number of line will be between 1 – 10,000.
Also, is it good idea to use array since this file might contains 10,000 of line?

Ex)
3:  1,  4,  5, 10, 14, 15, 16, 19, 22, 25, 26, 37, 38, 42, 50, 56, 62, 70, 74, 80
1:  6, 12, 27, 28, 29, 30, 33, 36, 37, 39, 41, 43, 46, 49, 56, 57, 59, 62, 73, 80
….

….
….
0
Comment
Question by:dkim18
1 Comment
 
LVL 9

Accepted Solution

by:
tinchos earned 100 total points
ID: 9843419
Hi dkim18,

If I were you I would not use an array but a map whose key is the line number and whose value is a list of numbers

typedef list< int > NumberList;
typedef map< int, NumberList > NumberMap;

There, you will be able to add like this

NumberList myList;

myList.push_back( 1 );
myList.push_back( 4 );
myList.push_back( 5 );
myList.push_back( 10 );
myList.push_back( 14 );

// And so on
NumberMap myMap;
myMap[ 3 ] = myList;

and that will store the first line of code

Hope this helps

Tincho
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now