It is impossible to find out the size of a dynamically allocated array (using new or malloc). sizeof can only find out the size of static arrays like buffer[54]. If it was dynamically allocated there is no way to find out. Your best bet is to add an argument to the function (just an int) to keep track of the size. Well in your case since it is a 2-D array, you would want to pass in 2 ints and that will be your sizes for each dimension.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.