>filename = strcat(filename, ".csv");
1. You're using gets()
2. Your buffer is too small
3. You append data with no regard to the size of the buffer.
>filename = strcat(filename, ".csv");
1. You're using gets()
2. Your buffer is too small
3. You append data with no regard to the size of the buffer.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.