Hello and can someone help me??..
Hello, I am new to this board and happy to have found it. I am working on a Lexical Analysis program and I have this large body of text (abstracts) that I need to separate. The main problem I am having is that the abstracts are separated with "\\\\\"
I have tried to save these \\\\\ as a string, constant string and char array and I keep on getting an error telling me that the newline is a constant. Any suggestions? I would be forever grateful!!
...never mind I think I figured it out...thank you anyway...
Since "\" is the start of C/C++ escape sequences you can't have an odd number of them like that. The compiler views the first 4 paired together as 2 single backslashes. The 5th is viewed as the start of a new escape sequence.
So if there's nothing behind it or a character that's not valid in an escape sequence then it's an error. If there is something behind it that is valid then it'll be viewed as the appropriate escape sequence.
//straight from MSDN
Character combinations consisting of a backslash (\) followed by a letter or by a combination of digits are called “escape sequences.” To represent a newline character, single quotation mark, or certain other characters in a character constant, you must use escape sequences. An escape sequence is regarded as a single character and is therefore valid as a character constant.
Escape sequences are typically used to specify actions such as carriage returns and tab movements on terminals and printers. They are also used to provide literal representations of nonprinting characters and characters that usually have special meanings, such as the double quotation mark ("). Table 1.4 lists the ANSI escape sequences and what they represent.
Note that the question mark preceded by a backslash (\?) specifies a literal question mark in cases where the character sequence would be misinterpreted as a trigraph. See Trigraphs for more information.
Table 1.4 Escape Sequences
Escape Sequence Represents
\a Bell (alert)
\n New line
\r Carriage return
\t Horizontal tab
\v Vertical tab
\' Single quotation mark
\" Double quotation mark
\? Literal question mark
\ooo ASCII character in octal notation
\xhhh ASCII character in hexadecimal notation