PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, July 19, 2022

[FIXED] How does printing 577 with %c output "A"?

 July 19, 2022     c, char, conversion-specifier, integer, printf     No comments   

Issue

#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')



Answered By - axelduch
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing