Make code compatible with other platforms, such as Unix, which uses slashes to separate paths. I believe that in Windows itself there are some special corner cases, for example, with device drivers.
Clarification of Josh's answer: Windows usually takes a slash for path separators, but not every Windows application, and there may be some places that Windows doesn't have either. For example, on the command line, a slash typically enters a parameter. Therefore, I would not personally rely on this.
I agree that in some situations there is quite a lot of something that you want to use. In my own (Delphi) code, I used the "AddSlash" method, which added, if necessary, a slash of the desired type. You can imagine a new language character or a character constant that is decoded to the right char for the platform.
source share