what is a "stray '\342' in program" - code (not much) and error below

Folks,

Still trying to learn. Now this error I have not seen before.

Best,

Tony

int n[ 10 ] ; // n is an array of 10 integers

void setup () {

}

void loop () {
   for ( int i = 0; i < 10; ++i ) { // initialize elements of array n to 0 {
      n[ i ] = 0; // set element at location i to 0
      Serial.print (i);
      Serial.print (‘\n’);
   }
   for ( int j = 0; j < 10; ++j ) { // output each array element's value {
      Serial.print (n[j]);
      Serial.print (‘\n’);
   } 
}

I/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino -I/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/variants/standard /var/folders/lr/wp0_4qm92dd27nqnnkggryy00000gn/T/arduino_build_914518/sketch/Arrays_examples.ino.cpp -o /var/folders/lr/wp0_4qm92dd27nqnnkggryy00000gn/T/arduino_build_914518/sketch/Arrays_examples.ino.cpp.o
Arrays_examples:11:21: error: stray '\342' in program
Serial.print (‘\n’);
^
Arrays_examples:11:22: error: stray '\200' in program
Serial.print (‘\n’);
^
Arrays_examples:11:23: error: stray '\230' in program
Serial.print (‘\n’);
^
Arrays_examples:11:24: error: stray '' in program
Serial.print (‘\n’);
^
Arrays_examples:11:26: error: stray '\342' in program
Serial.print (‘\n’);
^
Arrays_examples:11:27: error: stray '\200' in program
Serial.print (‘\n’);
^
Arrays_examples:11:28: error: stray '\231' in program
Serial.print (‘\n’);
^
Arrays_examples:15:21: error: stray '\342' in program
Serial.print (‘\n’);
^
Arrays_examples:15:22: error: stray '\200' in program
Serial.print (‘\n’);
^
Arrays_examples:15:23: error: stray '\230' in program
Serial.print (‘\n’);
^
Arrays_examples:15:24: error: stray '' in program
Serial.print (‘\n’);
^
Arrays_examples:15:26: error: stray '\342' in program
Serial.print (‘\n’);
^
Arrays_examples:15:27: error: stray '\200' in program
Serial.print (‘\n’);
^
Arrays_examples:15:28: error: stray '\231' in program
Serial.print (‘\n’);
^
/Users/tonyperry/Documents/Arduino/Arrays_examples/Arrays_examples.ino: In function 'void loop()':
Arrays_examples:11:29: error: no matching function for call to 'print(int [10])'
Serial.print (‘\n’);
^
In file included from /Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Stream.h:26:0,
from /Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/HardwareSerial.h:29,
from /Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Arduino.h:233,
from /var/folders/lr/wp0_4qm92dd27nqnnkggryy00000gn/T/arduino_build_914518/sketch/Arrays_examples.ino.cpp:1:
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:68:12: note: candidate: size_t Print::print(char)
size_t print(char);
^~~~~
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:68:12: note: conversion of argument 1 would be ill-formed:
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:69:12: note: candidate: size_t Print::print(unsigned char, int)
size_t print(unsigned char, int = DEC);
^~~~~
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:69:12: note: conversion of argument 1 would be ill-formed:
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:70:12: note: candidate: size_t Print::print(int, int)
size_t print(int, int = DEC);
^~~~~
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:70:12: note: conversion of argument 1 would be ill-formed:
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:71:12: note: candidate: size_t Print::print(unsigned int, int)
size_t print(unsigned int, int = DEC);
^~~~~
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:71:12: note: conversion of argument 1 would be ill-formed:
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:72:12: note: candidate: size_t Print::print(long int, int)
size_t print(long, int = DEC);
^~~~~
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:72:12: note: conversion of argument 1 would be ill-formed:
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:73:12: note: candidate: size_t Print::print(long unsigned int, int)
size_t print(unsigned long, int = DEC);
^~~~~
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:73:12: note: conversion of argument 1 would be ill-formed:
Arrays_examples:15:29: error: no matching function for call to 'print(int [10])'
Serial.print (‘\n’);
^
In file included from /Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Stream.h:26:0,
from /Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/HardwareSerial.h:29,
from /Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Arduino.h:233,
from /var/folders/lr/wp0_4qm92dd27nqnnkggryy00000gn/T/arduino_build_914518/sketch/Arrays_examples.ino.cpp:1:
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:68:12: note: candidate: size_t Print::print(char)
size_t print(char);
^~~~~
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:68:12: note: conversion of argument 1 would be ill-formed:
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:69:12: note: candidate: size_t Print::print(unsigned char, int)
size_t print(unsigned char, int = DEC);
^~~~~
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:69:12: note: conversion of argument 1 would be ill-formed:
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:70:12: note: candidate: size_t Print::print(int, int)
size_t print(int, int = DEC);
^~~~~
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:70:12: note: conversion of argument 1 would be ill-formed:
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:71:12: note: candidate: size_t Print::print(unsigned int, int)
size_t print(unsigned int, int = DEC);
^~~~~
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:71:12: note: conversion of argument 1 would be ill-formed:
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:72:12: note: candidate: size_t Print::print(long int, int)
size_t print(long, int = DEC);
^~~~~
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:72:12: note: conversion of argument 1 would be ill-formed:
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:73:12: note: candidate: size_t Print::print(long unsigned int, int)
size_t print(unsigned long, int = DEC);
^~~~~
/Users/tonyperry/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Print.h:73:12: note: conversion of argument 1 would be ill-formed:
exit status 1
stray '\342' in program

Let me guess: You copied and pasted the code from the web.
It has stray unicode character in it, which look like spaces but are NOT spaces.
Select the code in your post above using the "select" link, copy it, and paste back into your project.
The forum will have magically fixed the problem...

Correct on all accounts. Thanks. Never knew about these phantom characters. I learn by cut, paste and play.

tperry724:
Correct on all accounts. Thanks. Never knew about these phantom characters. I learn by cut, paste and play.

NP. Not your fault. Problem with whatever site present the code. The HTML should not contain these characters in the first place.

If you need to fix code yourself:
Tools -> Fix Encoding & Reload

Or:

  1. Paste into Notepad
  2. Save as...
  3. Select "Encoding: ANSI" at the bottom of the "Save As" window
    Unrecognised characters will be converted to ?

Great ideas. Thank you!