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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:25:52+00:00 2026-06-16T22:25:52+00:00

I have this character array char array[] = {1,2,3}; //FL, FH, Size and I

  • 0

I have this character array

char array[] = {1,2,3};     //FL, FH, Size

and I am trying to access it using pointers in such a way that I get FLFH value together, stored in an integer variable.

I did this

int val =0;
val = *(int*)array;
printf("value of p is %d\n",val);

I was expecting the result to be 12, but it was some 8-digit number which I think maybe the address of the value or something. Could anyone tell me what am I doing wrong here?

  • 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-16T22:25:53+00:00Added an answer on June 16, 2026 at 10:25 pm

    It’s never going to give you twelve.

    You’re taking two one-byte values and looking at them as if they comprise a single two-byte entity. When you look at them together, you’re re-interpreting their value. The integer 1 looks like this, as bits: 00000001, and 2 like this: 00000010. The compiler knows how big they are and thus will allow you to access them as individuals, but they’re laid out in order in your array, right next to each other in memory.

    Inspect the two bytes together as if they were an int, and you have: 0000000100000010, whose value is not 12; it’s 513.

    For your further reading, what you’re doing is a kind of “type punning”.

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

Sidebar

Related Questions

I have the following character array: char mychars[SIZE]; I would like to copy one
I have a string that contains a czech character. the string is 0bálka This
I'm working on the class that simply contains a character array and it's size
I have a large character array in the device global memory that is accessed
i am currently trying to assign each character that i get from a file
I have an array of characters declared as: char *array[size]; When I perform a
I have a function that takes 2 D character array as parameter class listview{
I am trying right now to declare a large character array. I am using
I have this function. And its goal is to take the last character first
I have an SVG file.This file shows the outline of cartoon character(2D character). My

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.