[Solved] fopen() crashing on second use in c [closed]


You create a pointer named buf that points to space containing a single character ‘\0’.
Then you use fgets() to try to read an unknown number of characters (you don’t show what maxvalue is) into the space pointed to by buf. But that space is only one character long. Reading into it will overrun the space, causing undefined behavior.

solved fopen() crashing on second use in c [closed]