Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8601921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:57:23+00:00 2026-06-12T01:57:23+00:00

I am having some challenges with a basic concept in C. Help would be

  • 0

I am having some challenges with a basic concept in C. Help would be much obliged.
I went ahead and annotated the code with the explanation of the code as well the question I am trying to ask there as well.

void main (void)
{
  printf("%x", (unsigned)((char) (0x0FF))); //I want to store just 0xFF;
  /* Purpose of the next if-statement is to check if the unsigned char which is 255
   * be the same as the unsigned int which is also 255. How come the console doesn't print
   * out "sup"? Ideally it is supposed to print "sup" since 0xFF==0x000000FF.
   */
  if(((unsigned)(char) (0x0FF))==((int)(0x000000FF))) 
     printf("%s","sup");
}

Thank you for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:57:24+00:00Added an answer on June 12, 2026 at 1:57 am

    You have gotten your parentheses wrong,

    if(((unsigned)(char) (0x0FF))==((int)(0x000000FF))) 
    

    performs two casts on the left operand, first to char, usually(1) resulting in -1, and then that value is cast to unsigned int, usually(2) resulting in 2^32-1 = 4294967295.

    (1) If char is signed, eight bits wide, two’s complement is used and the conversion is done by just taking the least significant byte, as is the case for the majority of hosted implementations. If char is unsigned, or wider than eight bits, the result will be 255.

    (2) If the cast to char resulted in -1 and unsigned int is 32 bits wide.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am having some trouble with the SkyDrive download process and hoping you can help
I am trying to build a web statistics website, however having some technical challenges.
LIVE CODE: http://jsfiddle.net/vy4nY/ I'm following this challenge , but I'm having some issues. I'm
I'm having some problems with authentication in iOS programming. I have a code that
I've been having some serious challenges over the past week trying to implement the
I am having some challenges with validation in my ASP.NET MVC3 project when using
Having some trouble with R's garbage collection, when passing objects to C++. We have
Having some annoying issues with loading images into a BufferedImage (image in the example)
Having some trouble getting a screenscraper webservice up and running on a weblogic 10.3.3
Having some issues getting my head around the differences between UTF-8, UTF-16, ASCII and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.