hey i am trying a code...ad in that i am using arayrs to store a sequence of data..i have writen this in he code x[100000] and it say too large arrays as a error......now how o deal with this..and how to store such a large sequence of data..without file handling...... how avoid this type of errors

Recommended Answers

All 4 Replies

Couldn't you just use string?

using namespace std;
int main()
{
    string variable;
    cout << "Enter some information: ";
    cin >> variable;
}

You can't just allocate a bazillion bytes on the stack, which is what happens if you make an allocation like:

char myBazillionBytes[100000000];

You are going to need to dynamically allocate room, either with new and delete[], or, probably best, use a vector, and don't worry about memory management.

Without file I/O though, how are you getting so much data? Surely nobody is going to sit and type it in?

i know that no one is going to type such enormous inputs..but still if you can suggest some gud tutorials over how to just not take care of memory management..........honestly this question i was asking becuse of this problem on codechef http://www.codechef.com/problems/INTEST/

To answer you question you can do this :

int main()
{
   int * largeInputArray = new int[1000000];

    //use array here, ex, largeInputArray[0] = 12312;

  //after done using largeInputArray
  delete [] largeInputArray;

 return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.