arrays in C

Hi for everyone,
I have a matrix that contains zero and nonzero elements
i want to do a function that return 3 arrays
the first one is for nonzero elementsthe second array contains the corresponding row numbersof eachnonzero elementthe third array contains the corresponding column numbers of each nonzero element

In, C you can NOT return arrays.
You can return pointers and structures; in addition to normal data type variables.

Tim S.

"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

I would start by writing code that display the matrix.
Write code the returns the columns of the matrix.
Write code the returns the rows of the matrix.

The above will help decide how to do the real task.

Edit: One way is to pass an array of bools (true/false) to a function; and set it to true/false based on if the column is all zeros.
Edt2: An other way is to use dynamic memory and return a pointer to that memory.

Tim S.

Last edited by stahta01; 03-17-2013 at 07:59 AM.

"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

How to call the function; note you need to declare the variables correctly.

Edit: I have no idea if you function does anything that is correct.

Code:

fonction(mat, n, m, tab1, tab2, tab3);

Last edited by stahta01; 03-17-2013 at 08:34 AM.

"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson