How to specify the apostrophy as a character constant

I've written a fairly comprehensive Morse code generator, everything working fine, except that I can't seem to test for the ' (apostrophy) character, because you use it to delimit the character.

Here's the section of code where it appears, and you can see I've had to remark it out because it won't compile, and I've put the "double-strike" method here (believing that's what you have to do), but also like "== '''

  if(ch == '~') sendmorse(8,1,1,1,1,1,1,1,1);
  if(ch == '&') sendmorse(5,0,1,0,0,0,0,0,0);
//  if(ch == '''') sendmorse(6,0,1,1,1,1,0,0,0);
  if(ch == '@') sendmorse(6,0,1,1,0,1,0,0,0);
  if(ch == ')') sendmorse(6,1,0,1,1,0,1,0,0);

There must be a way to enter this so that it work. Can anyone suggest please ...

TIA, and have a happy new year...

'\''
Like that

You need to escape the character

char testChar = '\'';

void setup()
{
  Serial.begin(115200);
  Serial.println(testChar);
  if (testChar == '\'')
  {
    Serial.println("matched");
  }
}

void loop()
{
}

Like it was imprisoned, give it a step-ladder to escape its confines ? Who dreamt that up ???

But thanks for all the replies ...

EDIT : Modifications made, code compiles without error, and appears to work 100%

C++ syntax can be daunting at times.. unless you've had 20 years experience, lol

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.