implicit declaration of function free is invalid in c99
You get that warning because you're calling a function without first declaring it, so the compiler doesn't know about the function.
All functions need to be declared before being called, there are no "built-in" functions in C.
It's true that free()
is a function defined in the standard, but it's still not built-in, you must have a prototype for it.
To figure out which header has the prototype, try searching for "man free" and look for a Linux manual page. Close to the top, it says:
#include <stdlib.h>void *malloc(size_t size);void free(void *ptr);void *calloc(size_t nmemb, size_t size);void *realloc(void *ptr, size_t size);
This tells you that in order to use the listed functions, you should add:
#include <stdlib.h>
to your source code.