0
\$\begingroup\$

I am trying to return a string.

String getBinary(String str) {

  String message = str;
  message.toLowerCase();
  int length = message.length();
  String binaryNumber = "";

  for(int i = 0; i <= length; i++) {

    char c = message.charAt(i);
    int letter = ;
    Serial.println(letter);

    binaryNumber = binaryNumber + String(c, BIN) + " ";

  }

  return binaryNumber;

}

But I get this error:

binary_telegraph.cpp: In function ‘String getBinary(String)’:
binary_telegraph.cpp:53:18: error: expected primary-expression before ‘;’ token

Any suggestions?

\$\endgroup\$
4
  • \$\begingroup\$ Which line is line 53? \$\endgroup\$
    – user17592
    Mar 31 '13 at 19:16
  • \$\begingroup\$ 53 : } That's the end of the for loop \$\endgroup\$ Mar 31 '13 at 19:17
  • 1
    \$\begingroup\$ Where is the electrical engineering problem? \$\endgroup\$ Mar 31 '13 at 21:27
  • \$\begingroup\$ @user1978786 FYI. Check out the proposed specialized Arduino board on SE. I bet, they would benefit from your participation. \$\endgroup\$ Mar 31 '13 at 22:20
4
\$\begingroup\$

This line

   int letter = ;

Is a syntax error. You can have either

   int letter;

or

   int letter = 1;  // need some number here
\$\endgroup\$
3
  • \$\begingroup\$ Oops! Sorry for the stupid question. Thanks for the answer though! \$\endgroup\$ Mar 31 '13 at 19:19
  • \$\begingroup\$ Angelatlarge, don't make all your answers community wikis! You won't earn reputation for them. \$\endgroup\$
    – user17592
    Mar 31 '13 at 19:19
  • \$\begingroup\$ For reference: meta.electronics.stackexchange.com/q/2818/17592. Interesting. \$\endgroup\$
    – user17592
    Mar 31 '13 at 19:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.