fgets will put the \n character in the buffer only if there is enough space...fgets(filename, sizeof(filename), stdin);
filename[strlen(filename)-1]='\0';
So better search for the presence of the \n character and not replace the last one without check. (see example in th eFAQ)
Also 100 bytes buffer maybe not long enough to store the file name with path
In windows MAX_PATH constant is at least 256 characters