This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Printf problem..

Hi,

This is my program.

int a = 0x0A;

printf("%c",a);

Why is it that the output from the serial port is 0x0D and 0x0A instead of just 0x0A itself?

Thanks..

Parents
  • "You just stated that it is a code. ASCII code."

    Yes, but so is 0x41. And that's an 'A'. It doesn't mean it isn't a character.

    "I don't think it is "extremely misleading"."

    Ok, totally wrong then.

    Every value in the range 0 to 127 is an ASCII character.

    "Sure, an ASCII terminal represents the 0x0A as a Line feed or Carriage return"

    Like I said, it's a linefeed.

    "but I don't think the user is that deep into the theory and is probably using it as an ascii character by the message"

    Yes, he is using it as an ASCII character. That's because it IS an ASCII character. But you've gone and told him it isn't.

    To be honest, I don't think that understanding what an ASCII character is is exactly being "deep into the theory". It's pretty fundamental stuff.

    Stefan

Reply
  • "You just stated that it is a code. ASCII code."

    Yes, but so is 0x41. And that's an 'A'. It doesn't mean it isn't a character.

    "I don't think it is "extremely misleading"."

    Ok, totally wrong then.

    Every value in the range 0 to 127 is an ASCII character.

    "Sure, an ASCII terminal represents the 0x0A as a Line feed or Carriage return"

    Like I said, it's a linefeed.

    "but I don't think the user is that deep into the theory and is probably using it as an ascii character by the message"

    Yes, he is using it as an ASCII character. That's because it IS an ASCII character. But you've gone and told him it isn't.

    To be honest, I don't think that understanding what an ASCII character is is exactly being "deep into the theory". It's pretty fundamental stuff.

    Stefan

Children
No data