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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:16:52+00:00 2026-06-04T21:16:52+00:00

My understanding about assigning an array to a pointer is that the pointer is

  • 0

My understanding about assigning an array to a pointer is that the pointer is pointing at the first index of the array, so when printout the pointer, it should print out the address of the first index of the array, but how come in this case the cout printed out the value of the whole array? even though I explicitly indicated that I wanted the address of the first index

char foo[] = {'A','B','C','\0'};
char* p = foo;
char* q = &(foo[0]);
cout <<"from p:  " << p << endl;
cout << "from q: " <<  q << " " << &(foo[0]) <<  endl;

//output
from p:  ABC
from q: ABC ABC

the second question is that I see the difference between those two lines is that one is an array of pointer to char, the other is a pointer to a char array, is that correct? is the parenthesis necessary?

 char* bar1[4];
 char (*bar2)[4] = &foo;
 cout << "address of foo is  " << bar2  << endl;
 //output
 address of foo is  0x7fff192f88b0

The address of the foo array should be the same as the address of A, right? How do I printout the address of A? since I failed to do so. Thank you very much

  • 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-04T21:16:53+00:00Added an answer on June 4, 2026 at 9:16 pm

    << has a dedicated overload for const char *, because that’s what a C-style string is. Try this:

    cout << static_cast<const void *>(bar2) << endl;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, I think that I don't have complete understanding about 3D/Game maths. But I
My understanding about CSS is that, generally if you set <div style=color: Red> ,
Until five minutes I was sure that my understanding about Objective c reference counting
There's something fundamental that I'm not understanding about presenting views that get their interface
as per my understanding about mvvm is. there is a model (entity class that
I have some clear understanding about Time slicing algorithm for CPU task scheduling.But i
I'm not a DBA, but I have some basic understanding about how SQL Server
First of all my understanding about scripting language after reading some stuff on web,
Below is my understanding about the log file group. Whenever innodb tables were inserted/updated
i'm new to c++ and having a little problem understanding about c++'s casting. According

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.