0

i am trying to save file data to int array their are three files and every file contain more than 1 million records and i don't know how to save this data to array..............
file look like
12000
135680
69857
5986
.
.
.
.
.
anyone please help me everytime i run the code the error show overflow.........................

2
Contributors
2
Replies
8
Views
1 Year
Discussion Span
Last Post by rubberman
0

You need to either store the data externally, or have plenty of memory. Don't use an array per-se, or you will get a stack overflow as you are seeing. Use a C++ vector<int> to store the data. It will resize itself intelligently as you add data to it. It will be on the heap so a stack overflow won't happen.

0

Also, if you want the data to be sorted, then use a set<int> or multiset<int>. A set is ordered, where a vector is not, and it will only allow unique values (duplicates are rejected). A multiset will allow multiple identical values, so it may be appropriate if you want to see how many instances of 1234 you have, for example.

Here is the reference doc for set/multiset: http://www.cplusplus.com/reference/set/

Edited by rubberman

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.