Hi there,
How to allocate a 2 dimension array using "new" operator?
How to pass a 2 dimension array to a function?
Is pointer always 4 bytes long or depends on system?
Thank you
Hi there,
How to allocate a 2 dimension array using "new" operator?
How to pass a 2 dimension array to a function?
Is pointer always 4 bytes long or depends on system?
Thank you
type ** name;
name = new type* [xlength];
for(int i = 0; i < xlength; i++)
{
name[i] = new type[ylenght];
}
//passing 2D array to function
foo(name);
to my knowledge pointers are always 4 bytes long.
does a command likeallocate 390*435906 bytes?(give or take a few)Code:char dummy[390][435906];
does a command like
allocate 390*435906 bytes?(give or take a few)Code:char dummy[390][435906];
well that would be 390 pointers (4 bytes each) to 390 different allocated areas of 435906 bytes. So i guess the minimum memory being allocated is (390*4)+(390*435906) = about 167Mb
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi