Error- total size of array must not exceed 0x7fffffff bytes

  • Thread starter Thread starter Shamprikta Mehreen
  • Start date Start date
S

Shamprikta Mehreen

Guest
My assignment is to run a stack operation 1) Millions of times and 2) Billions of times. And calculated the execution time. but i am getting this error- total size of array must not exceed 0x7fffffff bytes
What should I do? Here's my code>>

#include<iostream>
#include <ctime>

#define MIL 1000000
#define BIL 1000000000
using namespace std;


int stack[1000000], top;

//stack initialization
void initStack() {
top = -1;
}

//push operation
void push() {
for( int i=top; i<=MIL; i++){
top++;
cout << top;
}

}
//pop operation
void pop() {
for (int i = MIL; i <= top; i--) {
top--;
}
}
//expaanding stack
void arrayexpand() {
long *p = new long[BIL];
for (int i = 0; i < BIL; i++) {
p = stack;
}
}
int main() {
int start_s = clock();
initStack();
push();
pop();


// calculate execution time
int stop_s = clock();
cout << "time: " << (stop_s - start_s) / double(CLOCKS_PER_SEC) * 1000 << endl;

system("PAUSE");
}

Continue reading...
 
Back
Top