This article has been archived. It is offered "as is" and will no longer be updated.
If program contains a string literal that is incorrectly split overmultiple lines the following error will occur:
error C 2001: newline in constant
Several other errors may be caused by this also. This sample willalso give errors C2065, C2121, C2143, and C2198 as a result of thenewline errors.
This is a common programming mistake. Special considerations mustbe taken to split a constant string over several lines.
The best method is to change the format string, as in the followingexample (this works because strings separated only by spaces, tabs,and/or newlines are concatenated as specified by the ANSIstandard):
printf("\n %s" " %s" " %s", "this", "is", "it");
The older and less-preferred method is to use continuation lines bytyping a backslash followed by a carriage return at the end of aline, as in the following example:
printf("\n %s\ %s\ %s", "this", "is", "it");
This is not as good as the previous example because the spaces atthe beginning of the continuation line become part of the string,unlike the first example.