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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:52:13+00:00 2026-06-10T16:52:13+00:00

Let’s take this example code: #include <stdio.h> int main(void){ int x = 1; if(*(char

  • 0

Let’s take this example code:

#include <stdio.h>

int main(void){
    int x = 1;
    if(*(char *)&x == 1) printf("little-endian\n");
    else printf("big-endian\n");
    return 0;
}

I have seen this (or similar one) instruction *(char *)&x multiple times and now i want to completely understand what does it mean!
I think it means:
1) take the address of the int variables
2) then cast it to a char pointer
3) then compare the first element of the “new char pointer” with the number 1.

Am i right?

  • 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-10T16:52:15+00:00Added an answer on June 10, 2026 at 4:52 pm

    You’re about right, but a better listing would be:

    1. Take the address of x
    2. Convert address into a pointer to character
    3. Dereference that pointer, i.e. read the first char at &x
    4. Compare character value to integer 1

    Note that this is rather edgy code, the read value will depend on the machine’s byte endianness.

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

Sidebar

Related Questions

let's say we have some simple code like this : private static void Main()
Let's say I have 2 functions: void function1(int *ptr) { printf(%d, *ptr); } and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Let's say I have this code: <p dataname=description> Hello this is a description. <a
Let say I've this URL: http://example.com/image-title/987654/ I want to insert download to the part
Let's take a common example how a haskell function can be called from a
Let's suppose I have this piece of code. foreach(string value in myList) { string
Let's use the code from the first section of this website. I don't see
Let's have an example like below: package xliiv.sandbox; import android.app.Activity; import android.os.Bundle; import android.util.Log;
Let me explain best with an example. Say you have node class that can

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.