i tried to write a program in C:
Here is a piece of code:
#include <stdio.h>
int i, left, right, largest = 0, n = 9;
int a[] = {23, 12, 22, 1, 4, 5, 16, 8, 9, 10};
int main()
{
sort(a);
//code to print sorted numbers here
return 0;
}
void sort(int a[])
{
buildheap(a);
for(i = n; i < 0; i--)
{
exchange(i, 0);
n = n - 1;
maxheap(a, 0);
}
}
It shows warnings like this:
heapsort.c:16: warning: conflicting types for âsortâ
Is this because i’m nto including conio.h ?
When i tried to include conio.h, the gcc compiler throws error that conio.h is not found.
Any link or explanation in detail about the above warning and its relevance/irrelevance to conio.h will be helpful
Update
Im sorry for missing basics here.
Thank you so much. My program is running fine now
It is because there is no declaration of
sort()prior to its use. If a function is not declared (or defined) before it is used an implicit declaration is generated (the compiler should have emitted implicit declaration warnings) with signatureint sort(). Either add a declaration or move the definition to beforemain().Possibly same problem with
buildheap(),exchange()andmaxheap(): I don’t recognise any of these functions.