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 1116195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T03:15:58+00:00 2026-05-17T03:15:58+00:00

So my code has in it the following: unsigned short num=0; num=*(cra+3); printf(> char

  • 0

So my code has in it the following:

unsigned short num=0;
num=*(cra+3);
printf("> char %u\n",num);

cra is a char*

The problem is that it is getting odd output, sometimes outputting numbers such as 65501 (clearly not within the range of a char). Any ideas?

Thanks in advance!

  • 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-05-17T03:15:58+00:00Added an answer on May 17, 2026 at 3:15 am

    Apparently *(cra+3) is a char of value '\xdd'. Since a char is signed, it actually means -35 (0xdd in 2’s complement), i.e. 0x…fffffdd. Restricting this to 16-bit gives 0xffdd, i.e. 65501.

    You need to make it an unsigned char so it gives a number in the range 0–255:

    num = (unsigned char)cra[3];
    

    Note:
    1. the signedness of char is implementation defined, but usually (e.g. in OP’s case) it is signed.
    2. the ranges of signed char, unsigned char and unsigned short are implementation defined, but again commonly they are -128–127, 0–255 and 0–65535 respectively.
    3. the conversion from signed char to unsigned char is actually -35 + 65536 = 65501.

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

Sidebar

Related Questions

I have the following code that has @item.ID from razor: <a href=# id=deleteitem(@item.ID)>Delete</a> When
Class 1 has the following code that generates the exception - -(IBAction) searchAllAction: (id)
The following code has concurrency issues. Here inDegVec is a global int * ,
I'm looking at some legacy code which has the following idiom: Map<String, Boolean> myMap
So I'm trying to play a video and the following code has worked for
I am generating a simple form with php. The following code has been reduced
I have a Spring Batch process which has following kind of code. <step id=step1
SOLVED. Code has been edited to reflect solution. Given the following GridView : <asp:GridView
The documentation has the following code var options = { host: 'www.google.com', port: 80,
I have tried the following code but has no effect: Imports system.Runtime.InteropServices <DllImport(UxTheme.DLL, BestFitMapping:=False,

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.