+ 1

What's wrong if I use string as "c::\\"

Hi Refer code below: It works fine. If I change the file name to c:\ (uncomment the commented line), it displays wiered results. What's wrong with this code ? https://sololearn.com/compiler-playground/ck4g81fjBLhc/?ref=app

12th Feb 2025, 7:51 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
4 odpowiedzi
+ 2
Sololearn compilers run on linux, so windows \\ would not be recognized. https://stackoverflow.com/questions/122455/handling-file-paths-cross-platform
12th Feb 2025, 9:28 AM
Bob_Li
Bob_Li - avatar
+ 2
Ketan Lalcheta oh, I see what you mean. the second string seems to be parsed into ..\Playground\ when used in cout... not sure if it's a Sololearn thing. But here is my workaround if you just want the string to be displayed: (you shouldn't actually use raw string as path, though) https://sololearn.com/compiler-playground/c1JjZMZjutfW/?ref=app
12th Feb 2025, 12:38 PM
Bob_Li
Bob_Li - avatar
+ 1
Sololearn deliberately put that into their batch run script some years back. They replace file paths in the output file stream with ..\Playground\. I think it was an effort to quell hacking their server. It's a fun challenge to find workarounds. I will leave it as an exercise for the reader.
12th Feb 2025, 5:10 PM
Brian
Brian - avatar
0
I am just using it as a string and not used as actual path of file system. It is a raw string for me named as file name. Is it something string has this restrictions imposed ?
12th Feb 2025, 11:19 AM
Ketan Lalcheta
Ketan Lalcheta - avatar