Why I can't use \ ?

I want to use: Keyboard.print("%USERPROFILE%\Documents")

But I cant use \ between quotation marks.

Thanks

Backslash is the escape character. You have to escape it ... using the escape character :slight_smile:

  Keyboard.print("%USERPROFILE%\\Documents\\")

Pieter

PieterP:
Backslash is the escape character. You have to escape it ... using the escape character :slight_smile:

  Keyboard.print("%USERPROFILE%\\Documents\\")

Pieter

Thanks you.

If you don't know what an "escape character" is, the short version is that it combines with the immediate next character to represent special characters that you would normally have a hard time typing. For example, '\t' represents a tab and '\n' represents a line break.

It also removes meaning from characters that would normally be given a special interpretation. Double quotes (") are used to enclose a string, so if you want to use double quotes in your string you need to use " so the compiler knows that is an actual double quote in your text and not meant to be a boundary.

This also means that \ can remove the special meaning from itself, which is why you need to use \ in the file path.