Program works for stdin but fails for a file.
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:
Code:
free(): invalid pointer
I could not find how free gets a invalid pointer from using getc(fp) instead of getc(stdin).
Can someone help me find the error?