Segmentation fault (core dumped) due to fgets – I think
While you can use malloc() here, it is not really necessary. You can #define a reasonable maximum line length, and declare a character array to hold the input. If you do this, you can remove the frees from your code. You also have an issue with the way that you are using fgets(). The trailing \n is kept by fgets(), but your comparisons are … Read more