I'm getting the error
Conflicting types for 'free'
on the call to free()
function below.
int main ( )
{
char fx [] = "x^2+5*x-1";
node * fxNode = buildTree(fx, sizeof(fx)/sizeof(char));
printf(deriveFromTree(fxNode)); // Should print "2*x+5"
free(fxNode);
return 0;
}
Can't figure out why. Not sure if this matter, but what's above it is
#include <stdio.h>
char opstack [5] = {'+','-','*','^', '\0'};
unsigned short int lowerOpPrecedence ( char, char, char * );
int stringToUnsignedInt ( char *, unsigned int * );
int stringToDouble ( char * , double * );
unsigned short int stringCompare ( char * , char * );
void stringCopy ( char * , char * );
typedef struct treeNode
{
char * fx;
char * op;
struct treeNode * gx;
struct treeNode * hx;
} node;
unsigned short int getNodeState ( node * );
node * buildTree ( char *, int );
char * basicDerivative ( char * );
char * derivateFromTree ( node * );
and what's below it is a bunch of function implementations.
You need to add #include <stdlib.h>
to provide the prototype for free()
.
Also, the recommended signature for main()
is int main (void)
.
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