standard c library for escaping a string.

Posted by rampion on Stack Overflow See other posts from Stack Overflow or by rampion
Published on 2010-04-27T21:47:46Z Indexed on 2010/04/27 22:13 UTC
Read the original article Hit count: 149

Filed under:
|
|

Is there a standard C library function to escape C-strings?

For example, if I had the C string:

char example[] = "first line\nsecond line: \"inner quotes\"";

And I wanted to print

"first line\nsecond line: \"inner quotes\""

Is there a library function that will do that transformation for me? Rolling my own just seems a little silly.

Bonus points if I can give it a length to escape (so it stops before or beyond the \0).

© Stack Overflow or respective owner

Related posts about c

    Related posts about string