Your problem lies here:
char* extension = "CSS";
You are creating a pointer to a char and then assigning it to the start of a string. Later, you're trying to use it like an array. While it does the assignment, it leads to some anomalies when you try to access the letters later. Instead, try creating it as a char array.
char extension = "CSS";
This will fix it, but I'll leave it to someone like @Kareem to explain the subtleties of what's going on.
If this answers your question, please click the check mark to accept. Let's keep up on forum housekeeping. ;-)