I am studying data structures and was asked to build a program that uses a stack to reverse lines of text. Here it is: https://pastebin.com/raw/CGq6ZaHM
The problem is: it works for the stdin (when I redirect some input into it), but when I call it with a file as argument, the following error appears:
I could not find how free gets a invalid pointer from using getc(fp) instead of getc(stdin).Code:free(): invalid pointer
Can someone help me find the error?