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?
asked Feb 26, 2010 at 10:35
neuromancerneuromancer
53.4k78 gold badges166 silver badges223 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
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
hlovdalhlovdal
26.3k10 gold badges93 silver badges163 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.
answered Aug 31, 2017 at 11:12
Saurav SahuSaurav Sahu
12.8k6 gold badges61 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
cokedudecokedude
3791 gold badge10 silver badges20 bronze badges
2
Offline
Зарегистрирован: 19.12.2020
Всем привет . Проблема с инициализацией дисплея nokia 5110. Взял скетч с инета для проверки . А компилятор выдал ошибку 342. Что это за ошибка я не смог найти . Прошу помочь. Вот скетч.
#include <LCD5110_Graph.h> #include <LCD5110_Basic.h> LCD5110 LCD(7, 6, 5, 4, 3); //обьявляем дисплей с указанием пинов подключения extern uint8_t SmallFont[]; //указываем наличие массива со шрифтом SmallFont в библиотеке extern uint8_t MediumNumbers []; //указываем наличие массива со шрифтом MediumNumbers в библиотеке void setup() { LCD.InitLCD(); //инициализируем дисплей } void loop() { LCD.disableSleep(); //выводим дисплей из режима сна LCD.clrScr(); //очищаем дисплей LCD.setFont(SmallFont); //устанавливаем шрифт SmallFont LCD.print(“Hello World!”, CENTER, 2); //выводим “Hello World!” на второй строчке с равнением по центру LCD.setFont(MediumNumbers); // устанавливаем шрифт MediumNumbers for (int i=0; i<=5; i++) { LCD.clrScr(); //очищаем экран LCD.print(i, CENTER, 20); //выводим значение i по центру 20 строчки delay(1000); } LCD.enableSleep(); //вводим дисплей в режим сна на время длительной паузы delay(5000);
-
#1
Оформи код соответствующим тэгом
#include <Servo.h>.
const int trigPin = 8;
const int echoPin = 9;
// defining time and distance
long duration;
int distance;
Servo myServo; // Object servo
void setup() {
pinMode(trigPin, OUTPUT); // trigPin as an Output
pinMode(echoPin, INPUT); // echoPin as an Input
Serial.begin(9600);
myServo.attach(10); // Pin Connected To Servo
}
void loop() {
// rotating servo i++ depicts increment of one degree
for(int i=15;i<=165;i++){ Вот тут вылезает ОШИБКА
myServo.write(i);
delay(30);
distance = calculateDistance();
Serial.print(i);
Serial.print(«,»);
Serial.print(distance);
Serial.print(«.»);
}
// Repeats the previous lines from 165 to 15 degrees
for(int i=165;i>15;i–){
myServo.write(i);
delay(30);
distance = calculateDistance();
Serial.print(i);
Serial.print(«,»);
Serial.print(distance);
Serial.print(«.»);
}
}
int calculateDistance(){
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance= duration*0.034/2;
return distance;
}
Loading
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
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
2