Problem: Can’t compile the code after clicking on Compile and Execute button, the output in DevC++ compiler panel show error [Error] stray \240 in the program.
The detailed error message as below:
[Error] stray '\240' in program
Follow the below solution steps to resolve stray \240 in program error.
Error: stray '\240' in program is a character encoding error message. \240 is a non-breaking space in iso8859-1 encoding used on web pages, especially when the code shouldn’t get line-wrapped by the browser. The compiler doesn’t understand non-breaking space and reports about a straying special character error.
- It appears you have illegal/invalid/invisible characters in your source, probably Unicode NO-BREAK SPACE characters, encoded as “\302\240” (octal), this generally comes when you copy and paste the code in an IDE from another website or document and there are some non-ASCII character encoding.
- Unacceptable words to the language got copied giving rise to this error.
- Copying and pasting from Adobe Acrobat and Adobe Reader may result in an error.
- If you had opened or edited your source code with an editor that enters non-breaking spaces instead of the common whitespace. That might happen if you push shift-space instead of only space, depending on the editor you use. In a trivial editor, you only see nothing as expected like when you push the space key.
Select one of these spaces and use Find and Replace function to substitute all matches with regular spaces.
Start with a new document with blank file, and rewrite the code manually instead of copying and pasting.
Write a simple program that reads the file, and replaces the \24′ characters with spaces.
Paste the code in Microsoft Word using the Keep text Only paste option, all the ASCII characters causing errors will be removed.
Copy and paste the code into Microsoft Word using the Keep Text Only paste option. This will remove any ASCII characters which may cause errors.
Copy the code to Wordpad then cut a single space from anywhere in that word file and use replace all to replace that space (which is cut) with another space key you entered.