Solved

Reading ile and parsing

Posted on 2003-11-29
1
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Socket Programming (Unix) 8 153
I could not build boost code, 10 106
Arduino EDI - Programming language 3 114
Embarcadero C++ Builder XE10.1 Berlin red arrow Indicator 2 70
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 how to clear a vector as well as how to detect empty vectors in C++.

762 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