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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:27:04+00:00 2026-06-11T13:27:04+00:00

For instance in my 64-bit ubuntu machine, the length of pointer is 2 byte

  • 0

For instance in my 64-bit ubuntu machine, the length of pointer is 2 byte and have 1 memory address, so Does it always be the 2 byte, no matter such long int or int it pointe to?

if so, What’s the point to determine the type of data it point to? In the code below, except for incompatible warning purpose, how many bytes, the data represents, by use the %hu and %lu, so no matter the pointer is int or long, the result is the same. Could anyone give me a hint?

#include <stdio.h>
int main(void) {
    int *ptr1;
    long int *ptr2;
    long int a = 0xffffffff;
    ptr1 = &a;
    ptr2 = &a;
    printf("the value should the same as 2 ** 16 %hu", *ptr1);
    printf("the value should the same as 2 ** 32 %lu", *ptr2);
    return 0;
}

update:

another purpose of determining the type of pointer that I can think of is for the pointer arithmetic like:

ptr + 1, it will skip the length of byte the datatype has, instead of alway certain value

  • 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-11T13:27:06+00:00Added an answer on June 11, 2026 at 1:27 pm

    I may be misinterpreting what you’re asking, and if I am, please accept my apologies in advance. I think what’s happening is that your confusing the notion of pointers in general with the notion of the type that any given pointer may reference.

    A pointer, regardless of the thing to which it points, is just an address in memory (however it is structured for a given environment or system). The type of data being referenced is critical in allocations (malloc, calloc, etc), because it does become important to know how many bytes of memory need to be allocated for a specific type/structure referenced by a given pointer. If you’re working with pointers to an array structure, the data size becomes even more critical if you increment a pointer reference, because the pointer increment can increment by the size of the data being referenced.

    You can declare a pointer type, but it doesn’t allocate anything. And the warning you’re receiving is the compiler’s way of telling you that it sees that you have, deliberately or accidentally, taken the address of one type of variable, but are risking trying to use it as an address of a different kind of variable.

    Let’s say an int takes four bytes, but a short int takes two. If you take a pointer to a short int, but write an int value to it, you’ll corrupt who knows what along the way. That’s precisely why its important to keep track of the kind of pointer you’re referencing, lest something Really Bad happens to your code at runtime.

    As I said, I may be misunderstanding the problem, and if I am, please accept my apologies. I hope this is helpful.

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

Sidebar

Related Questions

Bit confused here, I have an on-demand instance but do I get charged even
For instance I have this bit of code public class ProductService{ private IProductDataSource _dataSource
Just i have a bit of confusion in understanding static reference. incase of instance
Im a bit confused about inherited instance variables in ABCs. I have written an
Have this bit of code in my app... Request::instance()->directory After upgrading to 3.1 it
My current instance is 32 Bit Windows 2008 server with 613 MB memory. I
I have a Windows server 2008 R2 64 bit with a VMware instance of
I have deployed mongodb 64 bit 2.x version on aws m1.large instance. I am
I am having a wee bit of trouble configuring my couchone instance. I have
Having a bit of a problem creating an instance of an object. Bear in

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.