C++ Relative Paths

Started by
12 comments, last by Xirion 11 years, 7 months ago
Thank you, it's good to know.
Advertisement

@Servant of the lord: the space was because if i don't use that space my letter "t" was erased.

' ' is an escape code for tab, in the same way '\n' is an escape code for a new line.
If you are using '\\' that shouldn't happen, and if you are using '/' it definitely won't happen.
You hit on something very important here, and this is ultimately the source of your problems.

In C++, literal string values use escape codes to present special characters.

For example \n is used in place of a newline, so:

"Hello\nWorld"

When evaluated becomes:
Hello
World

While you escape the escape character ( \ ) using predictably enough, the escape character, so if you wanted to say:

Hello\World

You would go:
"Hello\\World"

'\ ' is such an escape code ( it is how you encode a TAB ).

This is why you should use "/" for your path values, such as:

c:/my/path/somewhere

This has the advantage of being portable to every other non-DOS based OS under the sun as well.


Edit: Ironically \ + t is how you encode a tab on this site aswell apparently.
sorry I do not think I expressed myself well, i meant that the letter "t" dessapeared but not in my code but in the post.
sorry for the confusion

This topic is closed to new replies.

Advertisement