What can create a lexical error in C?

DrBeco picture DrBeco · Apr 4, 2011 · Viewed 12.6k times · Source

Besides not closing a comment /*..., what constitutes a lexical error in C?

Answer

Ira Baxter picture Ira Baxter · Apr 4, 2011

Here are some:

 "abc<EOF>

where EOF is the end of the file. In fact, EOF in the middle of many lexemes should produce errors:

 0x<EOF>

I assume that using bad escapes in strings is illegal:

  "ab\qcd"

Probably trouble with floating point exponents

 1e+%

Arguably, you shouldn't have stuff at the end of a preprocessor directive:

#if x   %