Writing char array to file, with escape characters written with their corresponding literals
<p>I'm trying to write a char array to file, the the escaped characters should be written with their equivalent literals (for example newline should be written as '\n' instead of actual line break in the file).</p>

<p>if the array is <code>char *arr = "hello world\n";</code>
my code should write</p>

<pre><code>char tempArr[100] ={'h','e','l','l','o','\s','w','o','r','l','d','\n'};
</code></pre>

<p>to the file.</p>

<p>is there any way to accomplish this in C++?</p>
