C free(): invalid pointer

You’re attempting to free something that isn’t a pointer to a “freeable” memory address. Just because something is an address doesn’t mean that you need to or should free it. There are two main types of memory you seem to be confusing – stack memory and heap memory. Stack memory lives in the live span of the function. … Read more

C error: undefined reference to function, but it IS defined

How are you doing the compiling and linking? You’ll need to specify both files, something like: …so that it knows to link the functions from both together. With the code as it’s written right now, however, you’ll then run into the opposite problem: multiple definitions of main. You’ll need/want to eliminate one (undoubtedly the one in … Read more