Thanks for all the comments! The string (with escape sequences) is user defined, so I need to expand the escape sequences during runtime, not compile time. I was hoping for a standard function, but it appears it may not exist. I'll adapt the below provided function (adding output length limit) and use it. THANKS! Harold > Was just thinking it a bit further: Do you have a non pre-compiled string= ? > Aka: > > char * OrigString =3D "This\\tis\\rinteresting"; ? > > (notice the double backslashes) > > Then you probably would need a conversion function, similar to this: > > char *o =3D OrigStr; > char *s =3D StringBuf; > while ( *o ) { > char c =3D *o++; > if ( c =3D=3D '\\' ) { > c =3D *o++; > switch(c) { > case '\0': break; > case 't': c =3D '\t'; break; > case 'n': c =3D '\r'; break; > case 'r': c =3D '\n'; break; > case 'a': c =3D '\a'; break; > default: break; > } > > *s++ =3D c; > } > } > *s =3D '\0'; > > (have not tested and it is definitely _unsafe_ -- for illustration purpos= e > only) > > Tamas > > > > On 13 May 2013 22:55, Tamas Rudnai wrote: > >> Have you tried in this way: >> >> sprintf(StringBuf, "%s", OriginalString); >> >> Tamas >> >> >> On 13 May 2013 20:06, Harold Hallikainen wrote: >> >>> I have a string, defined at run time, that includes standard printf >>> escape >>> sequences (such as \t and \r). I'd like to change these back to tab and >>> carriage return. I tried using sprintf(StringBuf,OriginalString), but >>> this >>> just copied OriginalString to StringBuf without expanding the escape >>> sequences. I note that the "format string" is defined as const char, so >>> I >>> guess it is evaluated at compile time instead of run time (especially >>> to >>> deal with a variable number of % substitutions). So, is there a >>> standard >>> function to expand out the escape sequences in a run-time defined >>> string? >>> Or do I have to write my own? >>> >>> THANKS! >>> >>> Harold >>> >>> >>> >>> -- >>> FCC Rules Updated Daily at http://www.hallikainen.com - Advertising >>> opportunities available! >>> Not sent from an iPhone. >>> -- >>> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive >>> View/change your membership options at >>> http://mailman.mit.edu/mailman/listinfo/piclist >>> >> >> >> >> -- >> int main() { char *a,*s,*q; printf(s=3D"int main() { char *a,*s,*q; >> printf(s=3D%s%s%s, q=3D%s%s%s%s,s,q,q,a=3D%s%s%s%s,q,q,q,a,a,q); }", >> q=3D"\"",s,q,q,a=3D"\\",q,q,q,a,a,q); } >> > > > > -- > int main() { char *a,*s,*q; printf(s=3D"int main() { char *a,*s,*q; > printf(s=3D%s%s%s, q=3D%s%s%s%s,s,q,q,a=3D%s%s%s%s,q,q,q,a,a,q); }", > q=3D"\"",s,q,q,a=3D"\\",q,q,q,a,a,q); } > -- > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 FCC Rules Updated Daily at http://www.hallikainen.com - Advertising opportunities available! Not sent from an iPhone. --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .