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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:40:33+00:00 2026-05-23T21:40:33+00:00

Is the size of a pointer the same as the size as the type

  • 0

Is the size of a pointer the same as the size as the type it’s pointing to, or do pointers always have a fixed size? For example…

int x = 10;
int * xPtr = &x;
char y = 'a';
char * yPtr = &y;

std::cout << sizeof(x) << "\n";
std::cout << sizeof(xPtr) << "\n";
std::cout << sizeof(y) << "\n";
std::cout << sizeof(yPtr) << "\n";

What would the output of this be? Would sizeof(xPtr) return 4 and sizeof(yPtr) return 1, or would the 2 pointers actually return the same size?

The reason I ask this is because the pointers are storing a memory address and not the values of their respective stored addresses.

  • 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-23T21:40:33+00:00Added an answer on May 23, 2026 at 9:40 pm

    Pointers generally have a fixed size, for ex. on a 32-bit executable they’re usually 32-bit. There are some exceptions, like on old 16-bit windows when you had to distinguish between 32-bit pointers and 16-bit… It’s usually pretty safe to assume they’re going to be uniform within a given executable on modern desktop OS’s.

    Edit: Even so, I would strongly caution against making this assumption in your code. If you’re going to write something that absolutely has to have a pointers of a certain size, you’d better check it!

    Function pointers are a different story — see Jens’ answer for more info.

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

Sidebar

Related Questions

I have a medium size Java file. Everytime I make a change to one
I have a lot of memory allocations and the same number of FreeMem calls.
I want to reinterpret cast a function pointer into a void* variable. The type
I have a problem caused by breaking strict pointer aliasing rule. I have a
I have two functions : void foo(const char * p) and template<size_t T_Size> void
gcc 4.4.4 c89 Pointers are not the same as arrays. But arrays can decay
I'll start with the code: typedef std::vector<unsigned char> CharBuf; static const int RCV_BUF_SIZE =
As I have so far learnt, a pointer is a place in memory (heap)
Would a constant-size array int x[20] be smaller than a dynamic array int *
I have the following problem. Consider the classes class face { virtual std::vector<ptr>& get_vertices(void)

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.