Find each length of a multidimensional array

Pages: 12
@Satsuma: You have a design flaw. If the code for dealing with the inventories is in the base class, why are the deriving classes responsible for allocating the inventories?
That is a very good question indeed, and although I didn't directly spot this I am fixing it by making an inventory class with all the functions for manipulation in so that if a Mob does need an inventory it can inherit, if it doesn't the it won't have the inventory and also will not have functions wasting memory and that could also be potentially dangerous if called.
Thanks for pointing that out though, I will have a scan through to make sure I don have anything else like this.
how about this little thingy:

#define COL 22
#define ROW 1
int _tmain(int argc, _TCHAR* argv[])
	int arr[COL][ROW], count1=0, count2=0;

	for (int i=0; i<COL; i++) {
		for (int j=0; j<ROW; j++) {
	cout << count1 << " " << count2/count1;
	return 0;
Where do you people come from?
L B (3767)Where do you people come from?

way to be helpful there, my friend..
and if that was directed to me, please show me the flaw in my code and then show me where yours is better.. of wait, you didn't post one, sorry..
I apologize for insulting you, but this is getting ridiculous. Please reread the entire thread and then read your post - it doesn't help the OP.
please enlighten me how is it not answering the question:
how do I find "size1" and "size2" individually?
In your example, how do you find the size of each dimension without using the #defines? The OP is using code like new int[blah];
Last edited on
that wasn`t perfectly clear from the OP.. but yeah, you have a point. Sorry about that.

std::vector < std::vector<int> > arr;
arr[0].size(); // first row size
arr.size(); // rows 
@L B Thanks for correcting stonedbear that he wasn't really getting the question but there was no need to be insulting (although it was only minor)

@stonedbear I didn't mention at all about using integer variables or macros but you even quotedmy question
how do I find "size1" and "size2" individually?
... I do hope you know the definition of the word "find"... And I was using "size1" and "size2" to reference the variables I wish to find for clarity, most understood this easily.
Also I am very greatful that LB pointed out that design flaw, it seems obvious when said but it can be difficult to notice some things like this (probably because not many people are daft enough like myself to do this kind of mistake).

@ALL Anyways sorry I meant to mark this as solved a little earlier and forgot
Thanks for all the help everyone's gave (and still thanks for those who's tried)
Last edited on
Don't consider yourself daft - we're human, and our brains don't always work as well as we want to.

In the future, try Rubber Duck Debugging - talking to people about your problems helps.
Last edited on
Topic archived. No new replies allowed.
Pages: 12