strcat(cmd, fName); you do not have place in the cmd to add there even one byte
change cmd declaration so the buffer be big enough to store the resulting string