Solved

Readinf file and parsing

Posted on 2003-11-29
1
263 Views
Last Modified: 2010-04-02
Hi!
I am trying to read the file below and store into 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 3

Accepted Solution

by:
gkatz earned 100 total points
ID: 9843680
depending on the file size it may not be a good idea to use a regular array.  Arrays are allocated in the stack and the stack has a limitted size.  Instead it may be a good idea to create the array at run time.  This has the added advantage that you can specify the size as a variable instead of a constant (once you create it, the size is still constant) and it is created on the heap instead of on the stack which means that you have a lot larger storage size.  To do so use the new operator.

double* myArray = new double[arraySize];

afte that you can use the array just like any standard array.  Just don't forget to deallocate it when you are done.

delete [] myArray;

-gkatz
0

Featured Post

Technology Partners: 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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

710 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