how do i change a file path which is in the form of `
c:\abc\efg\mmm.txt
to
c:\\abc\\mm.txt ?
and what can i do to change the
.txt
extension to, let’s say .doc?
`
EDIT:
These paths are just for illustration.
The actual paths are composed of drive letters and any number of subdirectories. And the file extensions can be of any format.
Your task is not quite clear. If you ONLY want to duplicate the backslashes AND it is pure C AND you don’t have wide chars (i.e. ASCII only), then you can do something along the lines of:
This will duplicate the backslashes. In order to replace the extension, to keep things simple, you may want to detect the extension using
int len = strlen(str);(may be as simple as checking last characters in thestr). Once done, you can replace thewhilecondition bywhile(p - str < len - 3)and thenstrcat(target, "doc");