errors.hlp (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.
Error Message
                                                  Contents Index Back
────────────────────────────────────────────────────────────────────────────
 
     Compiler error C2001
 
     newline in constant
 
     A string constant was continued onto a second line without either
     a backslash or closing and opening quotes.
 
     To break a string constant onto 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 two examples demonstrate causes of this error:
 
          printf("Hello,
              world");
         or
          printf("Hello,\n
              world");
 
     The following two examples show ways to correct this error:
 
          printf("Hello,\
           world");
         or
          printf("Hello,"
              " world");
 
     Note that any spaces at the beginning of the next line after a
     line-continuation character are included in the string constant.
     Note, also, that neither solution actually places a newline
     character into the string constant. To embed this character:
 
          printf("Hello,\n\
          world");
         or
          printf("Hello,\
          \nworld");
         or
          printf("Hello,\n"
              "world");
         or
          printf("Hello,"
              "\nworld");
                                    -♦-