Ternary operator in sprintf changes bool value

Can anyone explain why the following:

  if (waitNext) {
    Serial.print("\nIt Changed!");
  }
  else
  {
    Serial.print("\nNo Change!");
  }
  sprintf(outdex, "\nprocessCC:(%X) (%X) waitNext: %s", cc, val, waitNext ? "true" : "false");
  Serial.print(outdex);
  if (waitNext) {
    Serial.print("\nIt Changed!");
  }
  else
  {
    Serial.print("\nNo Change!");
  }

results in the following output?

No Change!
processCC:(6B) (0) waitNext: false
It Changed!

It seems that the ternary operator changed the value, but I thought this was a standard usage for printing a bool.

How big is the outdex buffer?

Oh, for goodness sake! How did I fall down that hole?

Thank you. Couldn't see the wood for the trees. :roll_eyes:

And we could not see your code because you had not posted it

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