Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stray '\342' in C++ program

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?

like image 279
neuromancer Avatar asked Feb 26 '10 10:02

neuromancer


People also ask

What does stray 342 in program mean?

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.

How do I fix error 342 on stray?

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.

What is stray error in C?

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.

How do I fix stray 342 error in Arduino?

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.


1 Answers

The symbol is not ". Those are called 'smart quotes' and are usually found in rich documents or blogs.

like image 97
LiraNuna Avatar answered Oct 18 '22 04:10

LiraNuna