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.

eg.

Do printf("Anything");

instead of  printf("Anything");

Content Summary

Potential Causes
Solution

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.
  • Copy and paste from Adobe Acrobat and Adobe Reader causes that 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

Solution 1

Selecting one of these spaces and use Find and Replace to replace all matches with regular spaces.

Solution 2

Start with a blank file, and rewrite the code by hand instead of copy and paste.

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.

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

    Ads Blocker Detected!!!

    This site depends on revenue from ad impressions to survive. If you find this site valuable, please consider disabling your ad blocker.