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'

Edited 5 Years Ago by vedro-compota: n/a

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?

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?

Comments

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.

Michigan Computer Repair

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...

This article has been dead for over six months. Start a new discussion instead.