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.

Alex Lim is a certified IT Technical Support Architect with over 15 years of experience in designing, implementing, and troubleshooting complex IT systems and networks. He has worked for leading IT companies, such as Microsoft, IBM, and Cisco, providing technical support and solutions to clients across various industries and sectors. Alex has a bachelor’s degree in computer science from the National University of Singapore and a master’s degree in information security from the Massachusetts Institute of Technology. He is also the author of several best-selling books on IT technical support, such as The IT Technical Support Handbook and Troubleshooting IT Systems and Networks. Alex lives in Bandar, Johore, Malaysia with his wife and two chilrdren. You can reach him at [email protected] or follow him on Website | Twitter | Facebook

    Ads Blocker Image Powered by Code Help Pro

    Your Support Matters...

    We run an independent site that is committed to delivering valuable content, but it comes with its challenges. Many of our readers use ad blockers, causing our advertising revenue to decline. Unlike some websites, we have not implemented paywalls to restrict access. Your support can make a significant difference. If you find this website useful and choose to support us, it would greatly secure our future. We appreciate your help. If you are currently using an ad blocker, please consider disabling it for our site. Thank you for your understanding and support.