2

I am attempting to get an output of:

Score: 
    0

but my output keeps coming out like

Score:        0

this is what I have implemented:

move_cursor(30,4);
printf_P(PSTR("Score : %8d\n"), get_score());
move_cursor(37, 8);

we are writing the score in Putty, from AVR to serial. What am I doing wrong?

FoggyDay
  • 11,962
  • 4
  • 34
  • 48
Mgert33
  • 83
  • 10
  • 2
    what is `move_cursor` ? – M.M May 29 '20 at 22:55
  • 1
    also can you explain how you expected `Score : %8d` to produce output with a line break and the number only having 4 spaces before it? – M.M May 29 '20 at 22:56
  • Why not do two writes, one for the "Score" label and another for the score itself? – tadman May 29 '20 at 22:57
  • @M.M move_cursor is to do with the output on the Putty program and where it is displayed on the output screen. – Mgert33 May 29 '20 at 22:58

1 Answers1

3

Q: If you want "0" on a separate line ... then shouldn't you put a matching `\n' in your format statement?

Q: If You want it right-aligned at column 6, then shouldn't your format statement be %6?

EXAMPLE: printf_P(PSTR("Score :\n%6d\n"), get_score());

PS:

As you're probably aware, "printf_P()" isn't standard C; it's AVR-specific.

FoggyDay
  • 11,962
  • 4
  • 34
  • 48