Hello ))
please tell me - where's the bug in this code -

``````main()
{ short int n = 0;

n=[U]getdet[/U] ( **m ,  n);
}
[B]short int ** [U]getdet[/U] (short int **m , int n) /*вычисляем определитель матрицы*/
{  short int c=0;
if (n==1) return **m;

}[/B]``````

compiler reports the following -

Type mismatch in redeclaration of 'getdet'

## All 9 Replies

sort of figured out ... function can't return type short int **

Exactly what are you trying to do??

commented: +++++ +1

I just wanted to return an integer value (preferably in the form of -

``short int **``

)))
if you know please tell me - can a function return a pointer?

ya a function can return a pointer.
Could you explain what is your program??

1. The compiler sees the call to getdet at line 4. It has to assume something about this symbol. The assumption is that it is a function returning int. At line 6 it sees that getdet is a function returning a pointer. This mismatches its previous assumption. Warning is emitted.
To avoid the warning, you have to be explicit: add a declaration

``short int ** getdet (short int **m , int n);``

above main.

2. You are trying to calculate a determinant - why returning the pointer at all?

commented: ++++ +1

Hello ))
please tell me - where's the bug in this code -

``````main()
{ short int n = 0;

n=[U]getdet[/U] ( **m ,  n);
}
[B]short int ** [U]getdet[/U] (short int **m , int n) /*вычисляем определитель матрицы*/
{  short int c=0;
if (n==1) return **m;

}[/B]``````

compiler reports the following -

getdet() itself a function. It does not return anything. this function itself give you the value.

Let's have a look at your program...

First thing if you are implementing a function then you need to declare that Function like

``short int ** getdat (short int ** ,int );``

now main() function use it like

``int main()``

you are using pointer to a pointer variable m but no declaration also m contains nothing.. it's suppose to store a address of a pointer.. first declare it

``int **m;``

getdet() function is returning pointer to a pointer type of value and you are directing it to a short int n.. also the way to passing address of m is wrong.
there are few more mistakes in your program.
i suggest first you learn passing pointer to a variable.. and describe your program briefly...

Wait... are you trying to get the determinant of a square matrix?

commented: ++++++ +1

Trentacle , yes it's so))

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.