Escape Character in directory path

R

Rich Strang

Hi

I need to pass a path to FindFirstFile() that is specified by the user,
problem is that all \ characters need to be prefixed with another \, what is
the easiest way to do this short of scanning the entire string and replacing
a \ with \\?

Kind Regards

Rich Strang
 
C

Clark Cox

Rich Strang said:
Hi

I need to pass a path to FindFirstFile()

First, I'll ignore this function, as it isn't standard C.
that is specified by the user,
problem is that all \ characters need to be prefixed with another \, what is
the easiest way to do this short of scanning the entire string and replacing
a \ with \\?

If you've already got a string that contains backslash characters
(i.e. entered by the user, read from a file, etc.), there is no need to
escape them. The escaping of backslashes is only needed in string and
character literals (i.e. in the source code).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,883
Members
47,414
Latest member
djangoframe

Latest Threads

Top