Меню

Error stray 342 in 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?

Peter Mortensen's user avatar

asked Feb 26, 2010 at 10:35

neuromancer's user avatar

neuromancerneuromancer

52.7k77 gold badges166 silver badges222 bronze badges

2

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

answered Feb 26, 2010 at 10:38

LiraNuna's user avatar

5

The lines

 size_t startpos = str.find_first_not_of(” t”); 
 size_t endpos = str.find_last_not_of(” t”); 

have some «special» kind of double quotes, try the following:

 size_t startpos = str.find_first_not_of(" t"); 
 size_t endpos = str.find_last_not_of(" t"); 

answered Feb 26, 2010 at 10:38

hlovdal's user avatar

hlovdalhlovdal

25.5k10 gold badges93 silver badges162 bronze badges

This sort of error message, error: stray ‘xyz’ in program, can appear with any other character or symbol that is not recognized by the compiler as a legal one.

Sharing my personal experience:

 - bool less<const char∗>(const char∗ a, const char∗ b)
 - bool less<const char*>(const char* a, const char* b)

The former one is copy-pasted from a PDF file. It doesn’t compile.

The latter one compiles as expected.

Peter Mortensen's user avatar

answered Aug 31, 2017 at 11:12

Saurav Sahu's user avatar

Saurav SahuSaurav Sahu

12.4k5 gold badges58 silver badges78 bronze badges

0

You can use the sed command to fix these issues.

This will give you a quick preview of what will be replaced.

sed s/[”“]/'"'/g File.txt

This will do the replacements and put the replacement in a new file called WithoutSmartQuotes.txt.

sed s/[”“]/'"'/g File.txt > WithoutSmartQuotes.txt

This will overwrite the original file.

sed -i ".bk" s/[”“]/'"'/g File.txt

answered Nov 13, 2014 at 13:27

cokedude's user avatar

cokedudecokedude

3591 gold badge10 silver badges20 bronze badges

2

You’re enclosing your string in the wrong kind of quotes.

You have:

“Hello Worldn”

You should instead have:

"Hello Worldn"

While the quotes you’ve used look similar, they are not recognized by a C compiler as enclosing a string. Thus, you get error messages about unrecognized Unicode characters, and you get error messages showing that the contents of the string are being interpreted as unquoted program code.

You will note that the quotes you’ve used have separate characters for beginning and ending a quotation (they are curved the way quotes are often typeset). Many word processors—as Jobin suggested—will automatically turn simple " quotes into such fancy quotation marks. If you’re using a word processor to compose C programs, you should use a text editor instead.

Ubuntu comes with gedit installed by default (though there are many other text editors to choose from, too). Like many text editors, gedit provides syntax highlighting for many programming languages including C (so different text in your program will shown in different colors to signify its meaning), which is a handy feature and makes a text editor much more convenient and user-friendly for programming than a word processor.

This might be Ubuntu-specific, if you’re used to a text editor on another platform that automatically reduces pasted quotations marks to the non-fancy version. But this question might end up getting closed and migrated to Stack Overflow.

When I try to compile my code it says «stray ‘342’ in program

My code:

#include <IRremote2.h>
#include <IRremoteInt.h>


#define pinIN 11

uint32_t val;
uint32_t prev;
int fre = 0;


IRrecv remote(pinIN);
decode_results result;

void setup() {
  Serial.begin(9600);

  remote.enableIRIn();
  pinMode(2, OUTPUT);
}

void loop() {
  if (remote.decode(&result)) {
    val = result.value;
    if (val == 0xFFFFFFFF) {
      val = prev;
    }
    prev = val;
    detekceKlaves();

    remote.resume();
  }
}

void detekceKlaves() {


  switch (val, HEX) {

    case 0x807FB24D‬:
      Serial.println("Stisknuto PLAY");
      tone(2, fre);
      break;
    case ‭0x807FB04F‬:
      Serial.println("Stisknuto STOP");
      noTone(2);
      break;
    case 0x807F18E7:
      Serial.println("Stisknuto VOL+");
      fre += 10;
      break;
    case 0x807F906F:
      Serial.println("Stisknuto VOL-");
      fre -= 10;
      break;
    case 0x807F9867:
      Serial.println("Stisknuto OFF/ON");
      fre = 0;
      break;
    default:
      Serial.println("Stisknuta jina klavesa");


  }
}

Error code:

Arduino: 1.8.10 (Windows 10), Board: "Arduino Uno"

irTEST:43:20: error: stray '342' in program

     case 0x807FB24D‬:

                    ^

irTEST:43:21: error: stray '200' in program

     case 0x807FB24D‬:

                     ^

irTEST:43:22: error: stray '254' in program

     case 0x807FB24D‬:

                      ^

irTEST:47:10: error: stray '342' in program

     case ‭0x807FB04F‬:

          ^

irTEST:47:11: error: stray '200' in program

     case ‭0x807FB04F‬:

           ^

irTEST:47:12: error: stray '255' in program

     case ‭0x807FB04F‬:

            ^

irTEST:47:23: error: stray '342' in program

     case ‭0x807FB04F‬:

                       ^

irTEST:47:24: error: stray '200' in program

     case ‭0x807FB04F‬:

                        ^

irTEST:47:25: error: stray '254' in program

     case ‭0x807FB04F‬:

                         ^

C:UsersmaximDocumentsArduinoirTESTirTEST.ino: In function 'void detekceKlaves()':

C:UsersmaximDocumentsArduinoirTESTirTEST.ino:43:5: warning: overflow in implicit constant conversion [-Woverflow]

     case 0x807FB24D‬:

     ^~~~

C:UsersmaximDocumentsArduinoirTESTirTEST.ino:47:5: warning: overflow in implicit constant conversion [-Woverflow]

     case ‭0x807FB04F‬:

     ^~~~

C:UsersmaximDocumentsArduinoirTESTirTEST.ino:51:5: warning: overflow in implicit constant conversion [-Woverflow]

     case 0x807F18E7:

     ^~~~

C:UsersmaximDocumentsArduinoirTESTirTEST.ino:55:5: warning: overflow in implicit constant conversion [-Woverflow]

     case 0x807F906F:

     ^~~~

C:UsersmaximDocumentsArduinoirTESTirTEST.ino:59:5: warning: overflow in implicit constant conversion [-Woverflow]

     case 0x807F9867:

     ^~~~

Multiple libraries were found for "IRremote2.h"
 Used: C:UsersmaximDocumentsArduinolibrariesIRremote2
exit status 1
stray '342' in program

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Please help

asked Dec 29, 2019 at 14:14

MaximMaximS's user avatar

3

If I copy your provided code in a vim-editor you can see some strange characters. <202c>

switch (val, HEX) {
  4 
  5     case 0x807FB24D<202c>:
  6       Serial.println("Stisknuto PLAY");
  7       tone(2, fre);
  8       break;
  9     case <202d>0x807FB04F<202c>:

I’ve removed them for you:

#include <IRremote2.h>
#include <IRremoteInt.h>

#define pinIN 11

uint32_t val;
uint32_t prev;
int fre = 0;

IRrecv remote(pinIN);
decode_results result;

void setup() 
{
  Serial.begin(9600);
  remote.enableIRIn();
  pinMode(2, OUTPUT);
}

void loop() 
{
  if (remote.decode(&result)) 
  {
    val = result.value;
    if (val == 0xFFFFFFFF) 
    {
      val = prev;
    }
    prev = val;
    detekceKlaves();
    remote.resume();
  }
}

void detekceKlaves() 
{
  switch (val, HEX) 
  {
    case 0x807FB24D:
      Serial.println("Stisknuto PLAY");
      tone(2, fre);
      break;
    case 0x807FB04F:
      Serial.println("Stisknuto STOP");
      noTone(2);
      break;
    case 0x807F18E7:
      Serial.println("Stisknuto VOL+");
      fre += 10;
      break;
    case 0x807F906F:
      Serial.println("Stisknuto VOL-");
      fre -= 10;
      break;
    case 0x807F9867:
      Serial.println("Stisknuto OFF/ON");
      fre = 0;
      break;
    default:
      Serial.println("Stisknuta jina klavesa");
  }
}

answered Dec 29, 2019 at 15:57

Peter Paul Kiefer's user avatar

2

trying to build project from chapter 8 MultithreadedCV in QtCreator under Archlinux I got :

/usr/bin/uic ../MultithreadedCV/mainwindow.ui -o ui_mainwindow.h
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../MultithreadedCV -I. -isystem /usr/local/include/opencv -isystem /usr/local/include -isystem /usr/include/qt -isystem /usr/include/qt/QtWidgets -isystem /usr/include/qt/QtGui -isystem /usr/include/qt/QtCore -I. -isystem /usr/include/libdrm -I. -I/usr/lib/qt/mkspecs/linux-g++ -o main.o ../MultithreadedCV/main.cpp
../MultithreadedCV/main.cpp:26:16: error: stray ‘342’ in program
         return “”;
                ^
../MultithreadedCV/main.cpp:26:17: error: stray ‘200’ in program
         return “”;
                 ^
../MultithreadedCV/main.cpp:26:18: error: stray ‘234’ in program
         return “”;
                  ^
../MultithreadedCV/main.cpp:26:19: error: stray ‘342’ in program
         return “”;
                   ^
../MultithreadedCV/main.cpp:26:20: error: stray ‘200’ in program
         return “”;
                    ^
../MultithreadedCV/main.cpp:26:21: error: stray ‘235’ in program
         return “”;
                     ^
../MultithreadedCV/main.cpp:32:31: error: stray ‘342’ in program
                       QString(“”).toStdWString().c_str(),
                               ^
../MultithreadedCV/main.cpp:32:32: error: stray ‘200’ in program
                       QString(“”).toStdWString().c_str(),
                                ^
../MultithreadedCV/main.cpp:32:33: error: stray ‘234’ in program
                       QString(“”).toStdWString().c_str(),
                                 ^
../MultithreadedCV/main.cpp:32:34: error: stray ‘’ in program
                       QString(“”).toStdWString().c_str(),
                                  ^
../MultithreadedCV/main.cpp:32:35: error: stray ‘342’ in program
                       QString(“”).toStdWString().c_str(),
                                   ^
../MultithreadedCV/main.cpp:32:36: error: stray ‘200’ in program
                       QString(“”).toStdWString().c_str(),
                                    ^
../MultithreadedCV/main.cpp:32:37: error: stray ‘235’ in program
                       QString(“”).toStdWString().c_str(),
                                     ^
../MultithreadedCV/main.cpp: In function ‘QString getVersionString(QString)’:
../MultithreadedCV/main.cpp:18:5: error: ‘DWORD’ was not declared in this scope
     DWORD dwHandle;
     ^~~~~
../MultithreadedCV/main.cpp:19:11: error: expected ‘;’ before ‘dwLen’
     DWORD dwLen = GetFileVersionInfoSize(fName.toStdWString().c_str(), &dwHandle);
           ^~~~~
../MultithreadedCV/main.cpp:21:5: error: ‘LPVOID’ was not declared in this scope
     LPVOID lpData = new BYTE[dwLen];
     ^~~~~~
../MultithreadedCV/main.cpp:22:58: error: ‘dwHandle’ was not declared in this scope
     if(!GetFileVersionInfo(fName.toStdWString().c_str(), dwHandle, dwLen, lpData))
                                                          ^~~~~~~~
../MultithreadedCV/main.cpp:22:58: note: suggested alternative: ‘drand48’
     if(!GetFileVersionInfo(fName.toStdWString().c_str(), dwHandle, dwLen, lpData))
                                                          ^~~~~~~~
                                                          drand48
../MultithreadedCV/main.cpp:22:68: error: ‘dwLen’ was not declared in this scope
     if(!GetFileVersionInfo(fName.toStdWString().c_str(), dwHandle, dwLen, lpData))
                                                                    ^~~~~
../MultithreadedCV/main.cpp:22:75: error: ‘lpData’ was not declared in this scope
     if(!GetFileVersionInfo(fName.toStdWString().c_str(), dwHandle, dwLen, lpData))
                                                                           ^~~~~~
../MultithreadedCV/main.cpp:22:75: note: suggested alternative: ‘QMapData’
     if(!GetFileVersionInfo(fName.toStdWString().c_str(), dwHandle, dwLen, lpData))
                                                                           ^~~~~~
                                                                           QMapData
../MultithreadedCV/main.cpp:22:9: error: ‘GetFileVersionInfo’ was not declared in this scope
     if(!GetFileVersionInfo(fName.toStdWString().c_str(), dwHandle, dwLen, lpData))
         ^~~~~~~~~~~~~~~~~~
../MultithreadedCV/main.cpp:25:18: error: type ‘<type error>’ argument given to ‘delete’, expected pointer
         delete[] lpData;
                  ^~~~~~
../MultithreadedCV/main.cpp:26:9: error: return-statement with no value, in function returning ‘QString’ [-fpermissive]
         return “”;
         ^~~~~~
../MultithreadedCV/main.cpp:29:5: error: ‘VS_FIXEDFILEINFO’ was not declared in this scope
     VS_FIXEDFILEINFO *lpBuffer = NULL;
     ^~~~~~~~~~~~~~~~
../MultithreadedCV/main.cpp:29:23: error: ‘lpBuffer’ was not declared in this scope
     VS_FIXEDFILEINFO *lpBuffer = NULL;
                       ^~~~~~~~
../MultithreadedCV/main.cpp:29:23: note: suggested alternative: ‘setbuffer’
     VS_FIXEDFILEINFO *lpBuffer = NULL;
                       ^~~~~~~~
                       setbuffer
../MultithreadedCV/main.cpp:30:5: error: ‘UINT’ was not declared in this scope
     UINT uLen;
     ^~~~
../MultithreadedCV/main.cpp:30:5: note: suggested alternative: ‘MIN’
     UINT uLen;
     ^~~~
     MIN
../MultithreadedCV/main.cpp:31:23: error: ‘lpData’ was not declared in this scope
     if(!VerQueryValue(lpData,
                       ^~~~~~
../MultithreadedCV/main.cpp:31:23: note: suggested alternative: ‘QMapData’
     if(!VerQueryValue(lpData,
                       ^~~~~~
                       QMapData
../MultithreadedCV/main.cpp:33:31: error: expected primary-expression before ‘)’ token
                       (LPVOID*)&lpBuffer,
                               ^
../MultithreadedCV/main.cpp:34:24: error: ‘uLen’ was not declared in this scope
                       &uLen))
                        ^~~~
../MultithreadedCV/main.cpp:34:24: note: suggested alternative: ‘QPen’
                       &uL``en))
                        ^~~~
                        QPen
../MultithreadedCV/main.cpp:31:9: error: ‘VerQueryValue’ was not declared in this scope
     if(!VerQueryValue(lpData,
         ^~~~~~~~~~~~~
../MultithreadedCV/main.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
make: *** [Makefile:603: main.o] Error 1
16:51:15: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project MultithreadedCV (kit: Desktop)
When executing step "Make"
16:51:15: Elapsed time: 00:03.
  • Forum
  • Beginners
  • error: stray ‘342’ in program

error: stray ‘342’ in program

trying a code for a simple game i downloaded. when i run it i get lines and lines of this error:
error stray ‘200’ in program (with different numbers)
— i’m using code::blocks, in case that matters….

what does this mean??
here are the first lines of the code. the first error (one in subject) points to line 36

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//Mine Field
#include <iostream> 
#include <exception> 
#include <string> 
#include <vector> 
#include <cstdlib> 
#include <ctime> 

using std::string;
using std::vector; 
using std::srand;
using std::time;


class StepOnMine {}; 
class FailedDisarm {}; 
class MineField 
{ 
	vector<bool> minefield; 

	//stores where the player has been 
	vector<bool> beenThere; 
	
	//current location of player
	int location; 

	int menu(string choices[], int numChoices)
	{
		using std::cout;
		using std::cin;

		int choice;
		do {
			for (int i = 0; i < numChoices; i++)
			{
				cout << i+1 << “) “ << choices[i] << “n”;
			}
			cin << choice;
		while (choice < 1 || choice > numChoices);
		return choice;
	}

thank you!!

Last edited on

Well, it is because there are “ and ” instead of » (note the slant!), and these characters are not valid.

………. it’s always the little things that matter 🙂

cin >> not <<

wow i guess there’s a lot wrong with this code.

I just got the same error doing something different now. In another example, i need to use this line:

#import «C:\Program Files\O2Gfxcore.dll»

does that mean the line is wrong or is the .dll library wrong?

Do you not notice the single backslash before fxcore.dll?

still getting the same error. I even moved the file to c: and used:

#import "C:\fxcore.dll"

and still same error

Could you copy and paste the error exactly?

Switch to forward slash / instead of double-backslashes. It works on Win, and means you don’t have to worry about double-slashes.

Which compiler (and preprocessor) are you using? Does it recognise #import? It’s not part of the C++ standard.

the code (i tried include in place of import, same problem):

1
2
3
4
5
6
7
8
9
10
#include <iostream>
#import "C:\fxcore.dll"

using namespace std;

int main()
{
   cout << "It works!!!n";
    return 0;
}

the error:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

Compiling: main.cpp
C:UsersSebastianDesktopcpp projectsranyatestmain.cpp:2:2: warning: #import is a deprecated GCC extension
In file included from C:UsersSebastianDesktopcpp projectsranyatestmain.cpp:2:
C:\fxcore.dll:1: error: stray '220' in program
In file included from C:UsersSebastianDesktopcpp projectsranyatestmain.cpp:2:
C:\fxcore.dll:1:4: warning: null character(s) ignored
C:\fxcore.dll:1: error: stray '3' in program
C:\fxcore.dll:1:6: warning: null character(s) ignored
C:\fxcore.dll:1: error: stray '4' in program
C:\fxcore.dll:1:10: warning: null character(s) ignored
C:\fxcore.dll:1: error: stray '377' in program
C:\fxcore.dll:1: error: stray '377' in program
C:\fxcore.dll:1:15: warning: null character(s) ignored
C:\fxcore.dll:1: error: stray '270' in program
C:\fxcore.dll:1:18: warning: null character(s) ignored
C:\fxcore.dll:1: error: stray '@' in program
C:\fxcore.dll:1:26: warning: null character(s) ignored
C:\fxcore.dll:1: error: stray '20' in program
C:\fxcore.dll:1: error: stray '1' in program
C:\fxcore.dll:1:63: warning: null character(s) ignored
C:\fxcore.dll:1: error: stray '16' in program
C:\fxcore.dll:1: error: stray '37' in program
C:\fxcore.dll:1: error: stray '272' in program
C:\fxcore.dll:1: error: stray '16' in program
C:\fxcore.dll:1:69: warning: null character(s) ignored
C:\fxcore.dll:1: error: stray '264' in program
C:\fxcore.dll:1: error: stray '315' in program
C:\fxcore.dll:1: error: stray '270' in program
C:\fxcore.dll:1: error: stray '1' in program
C:\fxcore.dll:1: error: stray '315' in program
C:\fxcore.dll:3:2: warning: null character(s) ignored
C:\fxcore.dll:3: error: stray '20' in program
C:\fxcore.dll:3: error: stray '311' in program
C:\fxcore.dll:3: error: stray '232' in program
C:\fxcore.dll:3: error: stray '232' in program
C:\fxcore.dll:3: error: stray '232' in program
C:\fxcore.dll:3: error: stray '365' in program
C:\fxcore.dll:3: error: stray '265' in program
C:\fxcore.dll:3: error: stray '232' in program
C:\fxcore.dll:3: error: stray '232' in program
C:\fxcore.dll:3: error: stray '267' in program
C:\fxcore.dll:3: error: stray '232' in program
C:\fxcore.dll:3: error: stray '232' in program
C:\fxcore.dll:3: error: stray '267' in program
C:\fxcore.dll:3: error: stray '232' in program
C:\fxcore.dll:3: error: stray '232' in program
C:\fxcore.dll:3: error: stray '241' in program
C:\fxcore.dll:3: error: stray '232' in program
C:\fxcore.dll:3: error: stray '232' in program
C:\fxcore.dll:3: error: stray '345' in program
C:\fxcore.dll:3: error: stray '232' in program
C:\fxcore.dll:3: error: stray '232' in program
C:\fxcore.dll:3: error: stray '267' in program
C:\fxcore.dll:3: error: stray '232' in program
C:\fxcore.dll:3: error: stray '232' in program
C:\fxcore.dll:3: error: stray '241' in program
C:\fxcore.dll:3: error: stray '232' in program
C:\fxcore.dll:3: error: stray '232' in program
C:\fxcore.dll:3: error: stray '232' in program
C:\fxcore.dll:3: error: stray '3' in program
C:\fxcore.dll:3: error: stray '232' in program
C:\fxcore.dll:3: error: stray '267' in program
C:\fxcore.dll:3: error: stray '232' in program

warning: #import is a deprecated GCC extension

Um…why are you using #import in that case?

Last edited on

Don’t use import. It seems that your preprocessor doesn’t recognise it.

Don’t #include a dll file. It’s meaningless. #include literally copies the entire file you want to include, and puts it into the place where you wrote #include .

Do not #include a dll file. I know I already said that, but I get the feeling saying it twice will help.

Why are you trying to #include a dll file? I think you must have misunderstood what a dll file is.

Last edited on

Topic archived. No new replies allowed.

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • Error ru centerinform transport crypto suncryptographer ошибка инициализации криптобиблиотеки
  • Error reading xmlstreamreader ошибка