Reputation: 15393
I had to made something for a little programm some days ago, I needed to turn a string like "foo\n"
into its stringified form (something like "\"foo\\n\""
).
But I found nothing, so I ended up writing my own function (and it worked fine). But I'm still wondering : Is there a function to stringify strings like this?
I know the python equivalent "%r" % strtostringify
, and I know that I can strinfifying pieces of code at compiling with preprocessor directives :
#define TOSTRING(X) #X
#define STRINGIFY(X) TOSTRING(X)
but is there a way to make it dynamically in C
?
Upvotes: 2
Views: 85
Reputation: 73366
Escaping special characters is not provided in any standard c function.
For GPL, you can take a look in standard c library for escaping a string.
Upvotes: 4