Go Down

Topic: Compile Error on Simple Subtraction (Read 323 times) previous topic - next topic

MaJiG

Here is a very simple sketch:
Code: [Select]

void setup()
{
  Serial.begin(9600);          // debug write to the USB
}

void loop()
{
  int vR = 0;       // reference voltage
  int vP = 0;               // potentiometer voltage
  int x = 0;                       // difference between the two
   
  vR = analogRead(A0);        // read vR to compare with vP
 
  vP = analogRead(A1);        // read vP to compare with vR

  x = vR - vP;                // calculate the difference
 
  Serial.print(x);            // write difference to console
}


Here are the compiler error messages:
minus:17: error: stray '\' in program
minus.ino: In function 'void loop()':
minus:17: error: expected `;' before 'u2013'

If I comment out the
  x = vR - vP;                // calculate the difference
line (17), it compiles OK.

I tried to search existing posts but didn't find an answer.

What gives???

Coding Badly


https://www.google.com/search?q=error:+stray+%27%5C%27+in+program+site%3Aarduino.cc%2Fforum

http://arduino.cc/forum/index.php/topic,109607.msg823129.html#msg823129

MaJiG

Retyped the minus and it all works! I must have cut n pasted at some point. Many thanks.

Go Up