|
From: Ioannis V. <no...@ho...> - 2002-05-10 19:19:45
|
Well, stack counting code had a bug, i was subtracting sizeof(unsigned
long) from kbytes instead of bytes. Anyway i fixed the bug and tweaked
it a bit, so here it is, SP1 :P . Well i want to be perfect that's why i
post the correct code. Sorry for the much code:
#include <iostream>
void stack()
{
using namespace std;
// Variable is created on the stack permanently and
// keeps its value between stack() calls (a nightmare
// for concurrency).
static unsigned long counter=0;
// sizeof(void *) to remove the size of the pointer the function call
// occupies itself on the stack
char buffer[1024-sizeof(void *)];
counter++;
cout<<"Allocated approximately "<<counter;
cout<<"KB of stack before i die\n";
stack();
}
int main()
{
stack();
}
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.cjb.net
<http://www.noicys.cjb.net/>
* Alternative URL: http://run.to/noicys
|