Hello and can someone help me??..

This is a discussion on Hello and can someone help me??.. within the C++ Programming forums, part of the General Programming Boards category; Hello, I am new to this board and happy to have found it. I am working on a Lexical Analysis ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    40

    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!!

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    40
    ...never mind I think I figured it out...thank you anyway...

  3. #3
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    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
    Escape Sequences
    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)
    \b Backspace
    \f Formfeed
    \n New line
    \r Carriage return
    \t Horizontal tab
    \v Vertical tab
    \' Single quotation mark
    \" Double quotation mark
    \\ Backslash
    \? Literal question mark
    \ooo ASCII character in octal notation
    \xhhh ASCII character in hexadecimal notation

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    40
    ...thank you...

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21