The simplest way is not to use the string you want to write as the format string, but as one of the argument to be formatted:
fprintf(fid2, '%s', mystring);
Alternatively, you could escape the '\':
fprintf(fid2, strrep(mystring, '\', '\\'));
Option 1 is more robust and should be faster.