-
June 2nd, 2014, 07:38 PM
#1
A question regarding forward slash and back slash
As we know in unix/linux, forward slash is always used for directory and in windows back slash is used for directory instead. On the other hand, I noticed that forward slash can be also used for directory in windows. But it doesn't always work properly. If I write a program that can be run in both linux and windows, what is best way to handle forward/back slash? Thanks for your inputs.
-
June 3rd, 2014, 08:17 AM
#2
Re: A question regarding forward slash and back slash
Originally Posted by dullboy
But it doesn't always work properly.
In what circumstances doesn't it work properly?
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman
-
June 3rd, 2014, 12:18 PM
#3
Re: A question regarding forward slash and back slash
Originally Posted by dullboy
On the other hand, I noticed that forward slash can be also used for directory in windows.
A forward slash can be used in any standard C++ or C file I/O function as the directory separator.
For specific Windows API functions, then you must be careful as to the direction of the slashes.
Regards,
Paul McKenzie
-
June 4th, 2014, 06:39 AM
#4
Re: A question regarding forward slash and back slash
note: some windows API functions support forward slashes as alias for backslash, some don't
it isn't typically documented, so it'll require testing. To make matters worse, things may differ from one version of windows to another as well.
Even some of the functions that do support it, will return paths with backslashes.
iirc, there's even a few oddball cases where the input string is converted to backslashes, even though the input parameter in the API is defined as a const-string. This could be a critical problem for some apps. This is a fatal error if said string is in a readonly section.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|