String.startsWith returning invalid results


cmd string. when use cmd.startswith(), returns false always, when check using serial port see right.
code: [select]
 
  serial.print("cmd=");
  serial.println(cmd);
  serial.print("cmd.startswith(\"fire:\")=");
  serial.println(cmd.startswith("fire:"));
  if (cmd.startswith("fire:")) <----------------------------- returns 0 always
  {
    cmd.replace("fire:","");
    serial.print("entered fire:");
    serial.println(cmd);


here serial output:
code: [select]

cmd=fire:a1999b1c1d9ef9gh9ij3kl9m1n1o1p1q1r1s1t
cmd.startswith("fire:")=0


what missing? worked until recently. have been working on unrelated section of code.

please help, confused....

thanks,
josh hawley

quote
this worked until recently.


that code should work.

as using strings, conscious of how ram have left? low ram can cause magical happen.
verify on stand alone sketch, basic functionality have posted above.


Arduino Forum > Using Arduino > Programming Questions > String.startsWith returning invalid results


arduino

Comments

Popular posts from this blog

Convierte tu Raspberry en un NAS. Firmware fvdw-sl 15.3 - Raspberry Pi Forums

How to format a Get Request

avrdude: verification error, first mismatch at byte 0x0000 0x0c != 0x62