hi .

i have read a line from a text file & stored it in a string using fgets().

the file contains the following line:

char myline[20];

now i want to append '\' in the string so that when i print myline output is


Any idea or algo how to do this in C ?

copy the string one character at a time into another variable that is long enough to hold the extra characters. When an '\' is encountered just copy two of them.

But I have to question your reason for doing that. When you type a path from the keyboard into a variable you don't need the couble '\' characters. They are only needed when you use string literals in your program because the compiler has to interpret the characters.

Thanks for the suggestion.