length of array filled with pointers?

  • Thread starter Thomas Deschepper
  • Start date
T

Thomas Deschepper

I'm writing a little matrix multiplication program, and for the moment, I
have to check if two matrices have the same dimensions. A matrix in my
program is an array of pointers. How can I check if two of those matrices
have the same dimensions, e.g.: 3*3?

Thank you, Thomas
--
Now I'm discovering your magazine, and I want to receive it by
email... The question is > How can I receive the magazine by email???

[ wget http://www.phrack.org/archive/phrack62.tar.gz;
puuencode phrack62.tar.gz p62.tar.gz | mail (e-mail address removed) ]
 
K

Kenneth Brody

Thomas said:
I'm writing a little matrix multiplication program, and for the moment, I
have to check if two matrices have the same dimensions. A matrix in my
program is an array of pointers. How can I check if two of those matrices
have the same dimensions, e.g.: 3*3?

By making a struct which includes a pointer to this matrix, along with a
height and width. Then, compare the height and width.
 
M

Malcolm

Thomas Deschepper said:
I'm writing a little matrix multiplication program, and for the moment, I
have to check if two matrices have the same dimensions. A matrix in my
program is an array of pointers. How can I check if two of those matrices
have the same dimensions, e.g.: 3*3?
A C pointer is normally implemented as just a bare address. There is
therefore no way of knowing what object a pointer points to, short of
keeping track of this information in the program (the C type system does a
lot of that for you).

What you need to do is declare

typedef struct
{
int width;
int height;
double *values;
} MATRIX;

Then the function is passed two MATRIX *s, and simply checks the width and
height fields.
 
T

Thomas Deschepper

Thomas said:
I'm writing a little matrix multiplication program, and for the moment, I
have to check if two matrices have the same dimensions. A matrix in my
program is an array of pointers. How can I check if two of those matrices
have the same dimensions, e.g.: 3*3?

Thank you, Thomas

Thx for the quick replies :)

--
Now I'm discovering your magazine, and I want to receive it by
email... The question is > How can I receive the magazine by email???

[ wget http://www.phrack.org/archive/phrack62.tar.gz;
puuencode phrack62.tar.gz p62.tar.gz | mail (e-mail address removed) ]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,147
Messages
2,570,833
Members
47,377
Latest member
MableYocum

Latest Threads

Top