No need for this memset.  Check the return from sscanf: if it's less than 2 (the number of items after the format string that we should have assigned on success) then it's failed; this should be handled.  Otherwise, it's 2 and filename got '\0'-terminated when sscanf() wrote to it.  No need to fill the rest of the buffer with '\0's.