0

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

4
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by firstPerson
0

Couldn't you just use string?

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

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?

0

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/

Edited by mayanktalwar: n/a

0

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;
}

Edited by firstPerson: n/a

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.