ccharintegerprintfconversion-specifier

How does printing 577 with %c output "A"?


#include<stdio.h>
int main()
{
  int i = 577;
  printf("%c",i);
  return 0;
}

After compiling, its giving output "A". Can anyone explain how i'm getting this?


Solution

  • %c will only accept values up to 255 included, then it will start from 0 again !

    577 % 256 = 65; // (char code for 'A')