![]() |
Why can't I use a backslash (e.g. "main\var") in my strings? |
Previous | Strings |
Q: |
When I type "main\var" , the compiler gives me an error. Help!
|
A: |
This is a common problem among beginning programmers.
The backslash (\ ) is used as an escape character in the C language.
Because of this, you need to modify your string to read like this: "main\\var" .
Now, compiler will interpret the \\ as a single backslash, which is what you want.
If you want to lean more about escape sequences, look at the information on strings. |