why does %d stand for Integer?

前端 未结 2 858
失恋的感觉
失恋的感觉 2020-12-12 20:22

I know this doesn\'t sound productive, but I\'m looking for a way to remember all of the formatting codes for printf calls. %s, %p,

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-12 20:49

    http://en.wikipedia.org/wiki/Printf_format_string seems to say that it's for decimal as I had guessed

    d,i

    int as a signed decimal number. '%d' and '%i' are synonymous for output, but are different when used with scanf() for input (using %i will interpret a number as hexadecimal if it's preceded by 0x, and octal if it's preceded by 0.)

提交回复
热议问题