top of page

FE1008/CY1402-"Error: stray '\240' in program"

If you have been copy-and-pasting my code, you might have faced this error when you compile using any IDE. This error is due to the presence of a special character ('\204') in the code that you have copy-and-pasted and the compiler will not compile due to the occurrence of this character in the code since it does not know what to do with this character.

Solution 1: Type the code yourself (Highly recommended)

If you were to type the code yourself (not copy-paste), you will definitely not face such an issue. Moreover, writing out the code yourself is a good practice so that you can become more familiar with the format and flow of the code.

Solution 2: Remove the spacing in the code

The spacing I am referring to here is the 4 spacebar whitespace before each line of code that I have included for formatting/indentation purposes. If you have copy-paste the whole lot of code, chances are that you have included this spacing and they are the reason for the error to occur. Remove them and your code should compile and work like how it should.

However, I do recommend that you add back the indentation to your code as a good practice. Good formatting improves code readability and sometimes it can help you spot errors in your code faster since your code is partitioned by these indentations.

My practice is to add a tab whitespace before every line inside a function and if I have any inner blocks, I will indent in further with another tab whitespace. In this way, it will be clear as to which part of the code belongs to the inner block and which part of the code belongs to the outer block. By default, in CodeBlocks, Visual Studio and many other IDEs, a tab space is usually set to be equivalent to 4 spacebar whitespace which is a standard used by many people. You can choose to change that value yourself in the whitespace settings in your IDE.

That's all for the topic on "Error: stray '\240' in program". If you have any doubts, opinions or suggestions, feel free to leave them in forum section or email me @ KYX@outlook.sg. Thanks~

Related Posts

See All
Recent Posts

Related Posts

Leave your comments or questions below:

bottom of page