so I'm trying to compile a multifile program using makefiles and header files etc. I've got this one program that I keep on getting the same error for even though I've double checked the type a million times. Help!
search.c:11: error: conflicting types for 'search'
search.h:1: note: previous declaration of 'search' was here
int search(struct intnode** root, int lookingfor, int* counter);
#include "search.h"
#include "intnode.h"
#include <stdlib.h>
#include <stdio.h>
/*
Usage:
search(root, value);
*/
int search(struct intnode** root, int lookingfor, int* counter) {
/*COMPARE TO ROOT KEY*/
/*IF EQUAL*/
if(int_compare(lookingfor, (*root)->key) == 0) {
printf("%d exists in tree", lookingfor);
counter++;
if ((*root)->R != NULL && (*root)->key == (*root)->R) {
search((*root)->R, lookingfor, *counter);
}
}
/*IF GREATER THAN AND THERE IS A CHILD*/
else if(int_compare(lookingfor, (*root)->key) == 1 && (*root)->R != NULL) {
search((*root)->R, lookingfor, *counter);
counter++;
}
/*IF LESS THAN AND THERE IS A CHILD*/
else if(int_compare(lookingfor, (*root)->key) == 2 && (*root)->L != NULL) {
search((*root)->L, lookingfor, *counter);
counter++;
}
return NULL;
}
Make sure intnode
is defined before search()
is declared.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With