Skip to Content

Solved: How do I fix the Error stray \240 error in DevC++ programming?

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.

Solved: How do I fix the Error stray \240 error in DevC++ programming?

Solved: How do I fix the Error stray \240 error in DevC++ programming?

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.


Do printf("Anything");

instead of  printf("Anything");

Content Summary

Potential Causes

Potential Causes

  • 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.


Solution 1

Select one of these spaces and use Find and Replace function to substitute all matches with regular spaces.

Solution 2

Start with a new document with blank file, and rewrite the code manually instead of copying and pasting.

Solution 3

Write a simple program that reads the file, and replaces the \24′ characters with spaces.

Solution 4

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.

Solution 5

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.

    Ads Blocker Image Powered by Code Help Pro

    It looks like you are using an adblocker.

    Ads keep our content free. Please consider supporting us by allowing ads on