C/C++ Compiler (cl.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
C2001
                                             Up Contents Index Back
────────────────────────────────────────────────────────────────────────────
 
     Compiler error C2001
 
     newline in constant
 
     A string constant was continued on a second line without either
     a backslash (\) or closing and opening double quotation
     marks (").
 
     To break a string constant that is on two lines in the source
     file, do one of the following:
 
        ■ End the first line with the line-continuation character, a
          backslash.
 
        ■ Close the string on the first line with a double quotation
          mark, and open the string on the next line with another
          quotation mark.
 
     It is not sufficient to end the first line with \n, the escape
     sequence for embedding a newline character in a string constant.
 
     The following are examples of incorrect and correct usage:
 
          printf("Hello,             // error
              world");
 
          printf("Hello,\n          //  error
              world");
 
          printf("Hello,\           //  OK
           world");
 
          printf("Hello,"            // OK
              " world");
 
     Note that any spaces at the beginning of the next line after a
     line-continuation character are included in the string constant
     and that neither solution actually places a newline character
     into the string constant. The following examples embed this
     character:
 
          printf("Hello,\n\
          world");
 
          printf("Hello,\
          \nworld");
 
          printf("Hello,\n"
              "world");
 
          printf("Hello,"
              "\nworld");
                                    -♦-