I'm getting these errors in my program after pasting in some code:
showdata.cpp:66: error: stray ‘\342’ in program
showdata.cpp:66: error: stray ‘\200’ in program
showdata.cpp:66: error: stray ‘\235’ in program
showdata.cpp:66: error: stray ‘\’ in program
showdata.cpp:66: error: stray ‘\342’ in program
showdata.cpp:66: error: stray ‘\200’ in program
showdata.cpp:66: error: stray ‘\235’ in program
showdata.cpp:67: error: stray ‘\342’ in program
showdata.cpp:67: error: stray ‘\200’ in program
showdata.cpp:67: error: stray ‘\235’ in program
showdata.cpp:67: error: stray ‘\’ in program
showdata.cpp:67: error: stray ‘\342’ in program
showdata.cpp:67: error: stray ‘\200’ in program
showdata.cpp:67: error: stray ‘\235’ in program
Here are the two lines that are causing the errors.
size_t startpos = str.find_first_not_of(” \t”);
size_t endpos = str.find_last_not_of(” \t”);
How can I fix this?
stray '\342' in program. This means that one of your double quotation marks are invalid Unicode characters. C and C++ don't allow "smart" quotes (i.e. ” vs "). This usually happens when you copy and paste code from other sources or use a text editor that uses Unicode.
The problem is that you have Unicode quotation marks instead of ASCII quotation marks; probably your editor automatically changed them, or you copied the text from a site that does this automatically in its authoring software. Replace the quotes with normal ASCII quote (0x22, ") and it should work.
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.
All you have to do is to remove the invalid characters. The invalid character may or may not be visible. If you cannot see any character just remove the space before the line. After removing all the invalid spaces and characters, your code will compile fine.
The symbol ”
is not "
. Those are called 'smart quotes' and are usually found in rich documents or blogs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With