Solved

Reading ile and parsing

Posted on 2003-11-29
1
179 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

Industry Leaders: 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
Which IDE to use to begin C++ training? 5 76
C++ Language error 28 312
C++ question 3 81
Need some help with Microsoft Visual Studio C++ 2003 5 86
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

734 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