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

  • Home
  • SEARCH
  • 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 101437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:46:16+00:00 2026-05-11T00:46:16+00:00

Given this field: char lookup_ext[8192] = {0}; // Gets filled later And this statement:

  • 0

Given this field:

char lookup_ext[8192] = {0}; // Gets filled later 

And this statement:

unsigned short *slt = (unsigned short*) lookup_ext; 

What happens behind the scenes?

lookup_ext[1669] returns 67 = 0100 0011 (C), lookup_ext[1670] returns 78 = 0100 1110 (N) and lookup_ext[1671] returns 68 = 0100 0100 (D); yet slt[1670] returns 18273 = 0100 0111 0110 0001.

I’m trying to port this to C#, so besides an easy way out of this, I’m also wondering what really happens here. Been a while since I used C++ regularly.

Thanks!

  • 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. 2026-05-11T00:46:16+00:00Added an answer on May 11, 2026 at 12:46 am

    The statement that you show doesn’t cast a char to an unsigned short, it casts a pointer to a char to a pointer to an unsigned short. This means that the usual arithmetic conversions of the pointed-to-data are not going to happen and that the underlying char data will just be interpreted as unsigned shorts when accessed through the slt variable.

    Note that sizeof(unsigned short) is unlikely to be one, so that slt[1670] won’t necessarily correspond to lookup_ext[1670]. It is more likely – if, say, sizeof(unsigned short) is two – to correspond to lookup_ext[3340] and lookup_ext[3341].

    Do you know why the original code is using this aliasing? If it’s not necessary, it might be worth trying to make the C++ code cleaner and verifying that the behaviour is unchanged before porting it.

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

Sidebar

Ask A Question

Stats

  • Questions 165k
  • Answers 165k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It's not possible (yet?). Sorry. May 12, 2026 at 1:10 pm
  • Editorial Team
    Editorial Team added an answer You would need to override the conversion operator, using either… May 12, 2026 at 1:10 pm
  • Editorial Team
    Editorial Team added an answer Do you have something strange in your djConfig? The fact… May 12, 2026 at 1:10 pm

Related Questions

I have a linked list, which stores groups of settings for my application: typedef
I have a table similar to this: CREATE TABLE example ( id integer primary
I have a protocol that requires a length field up to 32-bits, and it
I have a demo database with a couple of hundred tables in it. Each

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.