424,985 Members | 1,861 Online
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

# Array Pointer Question

 P: n/a I'm almost embarrassed to ask this because it seems like a complete newbie question, but here goes. How do I find out the size of an array of pointers that defines a 2D matrix called 'matrix0' when the only declaration I can find is "double **matrix0". After that declaration the next time the matrix is used is to assign values from: "matrix0 = stamps[istamp].mat;" Is its size actually determined by the size of stamps[]? Kind Regards, Matt Aug 8 '07 #1
6 Replies

 P: n/a On Aug 8, 12:09 pm, Matt

 P: n/a Matt I'm almost embarrassed to ask this because it seems like a completenewbie question, but here goes.How do I find out the size of an array of pointers that defines a 2Dmatrix called 'matrix0' when the only declaration I can find is"double **matrix0". After that declaration the next time the matrix isused is to assign values from:"matrix0 = stamps[istamp].mat;"Is its size actually determined by the size of stamps[]?Kind Regards,Matt Actually having just written it out I realised that matrix0 could just be a variable to temporarily store matrix values. Does that sound plausible No. matrix0 will point to the same place as stamps[istamp].mat (this might be a an array, or it might also be a pointer elsewhere) so assignments to matrix0[..][..] will not be to anywhere 'temporary'. To answer your original question, you can't find out the size from the pointer alone. If the size is important, it will be in stored in the program somewhere and you need to get it (or calculate it) from that data. I'd look and the other fields in stamps[istamp] first. -- Ben. Aug 8 '07 #3

 P: n/a On Aug 8, 2:22 pm, Ben Bacarisse

 P: n/a Matt wrote: > .... snip ... > Basically I'm redefining this matrix in GSL form (http://www.gnu.org/ software/gsl/manual/html_node/Matrix-allocation.html) so to define the matrix I need to state what size matrix0 needs to be. However i can't find a malloc allocation for stamps.mat any more then I could for matrix0. Just run a cross-ref on your source, and then examine the lines/files indicated under stamps. If it never gets initialized you have exposed a major flaw. :-) -- Chuck F (cbfalconer at maineline dot net) Available for consulting/temporary embedded and systems. -- Posted via a free Usenet account from http://www.teranews.com Aug 8 '07 #5

 P: n/a On Aug 8, 4:01 pm, CBFalconer -- Posted via a free Usenet account fromhttp://www.teranews.com How would you recommend I do this? I've been trying to use DDD to debug and show the variables but it's a little fiddly to work with. Kind Regards, Matt Aug 8 '07 #6

 P: n/a Matt wrote: CBFalconer Matt wrote:... snip ... >>Basically I'm redefining this matrix in GSL form(http://www.gnu.org/software/gsl/manu...llocation.html)so to define the matrix I need to state what size matrix0 needsto be. However i can't find a malloc allocation for stamps.matany more then I could for matrix0. Just run a cross-ref on your source, and then examine thelines/files indicated under stamps. If it never gets initializedyou have exposed a major flaw. :-) How would you recommend I do this? I've been trying to use DDD to debug and show the variables but it's a little fiddly to work with. Read the docs on your cross-ref utility, or write your own. It's not hard. What it is is off-topic for this newsgroup. -- Chuck F (cbfalconer at maineline dot net) Available for consulting/temporary embedded and systems. -- Posted via a free Usenet account from http://www.teranews.com Aug 9 '07 #7

### This discussion thread is closed

Replies have been disabled for this discussion.