help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using fprintf to output a .tex file


From: Graham Toal
Subject: Re: Using fprintf to output a .tex file
Date: Mon, 17 Jun 2013 13:49:40 +0000

> > s=[s '\\end{document}\n'];
> fprintf(file,s);

The underlying problem is that you are printf'ing the actual string rather than 
fprintf(file,"%s", s) ... if you do it that way, you not only have to escape 
backslashes, you have to escape any character that is special to printf which 
includes "%".  It's almost certainly a '%' that caused the format error you 
mentioned.

Rather than write complex code to protect the strings, just use "%s" and 
side-step the problem if you can.

Regards,

Graham


reply via email to

[Prev in Thread] Current Thread [Next in Thread]