Originally posted by mindrebel
b) it seems like defining an array size must be done with only constans, is it really just this way? if not, how can I define
one (array) with variables (like int A[x][y]?
Use dynamic allocation (new for C++ and malloc() for C). I'm not sure about the syntax for malloc() (always used new ), but it is something like this:
Code:
//Create a pointer
int* MyPointer;
//Allocate memory
MyPointer=malloc(SizeX*SizeY);
//Check if the allocation was successful
if(MyPointer!=NULL)
{
//*** Do whatever you want ***
MyPointer[y*SizeX+x]=56;
//Deallocate the memory. If you don't do this, you
//will end up with memory leaks. ONLY deallocate if it
//has been allocated, might crash otherwise...
free(MyPointer);
}