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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:31:29+00:00 2026-05-16T05:31:29+00:00

Why does the following code output 4 ? char** pointer = new char*[1]; std::cout

  • 0

Why does the following code output 4?

char** pointer = new char*[1];
std::cout << sizeof(pointer) << "\n";

I have an array of pointers, but it should have length 1, shouldn’t it?

  • 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-16T05:31:30+00:00Added an answer on May 16, 2026 at 5:31 am

    pointer is a pointer. It is the size of a pointer, which is 4 bytes on your system.

    *pointer is also a pointer. sizeof(*pointer) will also be 4.

    **pointer is a char. sizeof(**pointer) will be 1. Note that **pointer is a char because it is defined as char**. The size of the array new`ed nevers enters into this.

    Note that sizeof is a compiler operator. It is rendered to a constant at compile time. Anything that could be changed at runtime (like the size of a new’ed array) cannnot be determined using sizeof.

    Note 2: If you had defined that as:

    char* array[1];
    char** pointer = array;
    

    Now pointer has essencially the same value as before, but now you can say:

     int  arraySize = sizeof(array); // size of total space of array 
     int  arrayLen = sizeof(array)/sizeof(array[0]); // number of element == 1 here.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the following code std::cout does not print the values, but printf does. Why
All, Why does the following code fail to compile for 'std::endl', but it's fine
Why does following code snippet doesn't work? It doesn't gives any error, but also
Why does the following code seg fault before returning: int main() { char iD[20];
What does the following code mean in Ruby? ||= Does it have any meaning
the following code #include <iostream> using namespace std; int main(){ char greeting[50] = goodmorning
The following code does not produce the expected output. Why? wchar_t* wchar_t_printf_return(wchar_t* formatstring, ...){
I have written the following code and was surprised at the output. I heard
Can anyone explain why the following code outputs what it does: char c =
I have a file encrypted using the following code in c: unsigned char ckey[]

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.