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

Thursday, August 18, 2022

[FIXED] What is the output of the array / pointer in this c code

 August 18, 2022     arrays, ascii, c, output, pointers     No comments   

Issue

    #include <stdio.h>

    int main()
     {

     char*str="↔⬆🙂12345";
     printf("%d",*str );
     return 0;
   }

please help me to find the output of the given code


Solution

Assuming the file is encoded using UTF-8, the string consists of these bytes in hex:

E2 86 94 E2 AC 86 F0 9F 99 82 31 32 33 34 35

On a system where char means unsigned char, the first char is 226.

On a two's-complement system where char means signed char, the first char is -30.

On a one's-complement system where char means signed char, the first char is -29.

This value will be promoted to an equivalent int, passed to printf, and printed.



Answered By - ikegami
Answer Checked By - Pedro (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