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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:11:45+00:00 2026-06-07T20:11:45+00:00

First, I read that: array &array &array[0] will all be the same as long

  • 0

First, I read that:

  • array
  • &array
  • &array[0]

will all be the same as long as “array” is really an array.
So I tried:

int main(){ 
     char ar[]={'a','b','c','\0'};
     printf("argument: &ar     %s\n",&ar);
     printf("argument: &ar[1]    %s\n",&ar[1]);
}

the output:

argument:&ar   abc  
argument:&ar[1]  bc

It seems that &ar is taken as a pointer to the first element instead of a pointer to “ar”, which itself is a pointer to the first element if I am not mistaken.

’cause that shouldn’t be how &(pointer to a char) are treated, I tried:

char a='s';
char *pa=&a;
printf("argument: &pa   %c\n",&pa);

The output for %c isn’t even a character.
Nor shouldn’t it be how a pointer to the first element of an array treated. I tried:

char *pa=&ar[0];
char **ppa= &pa;
printf("argument: &pa   %s\n", ppa);

The output for %s is, not surprisingly, nonsense; but why hasn’t &ar been nonsense? For if ar were a pointer, shouldn’t &ar be as much a pointer to a pointer as is ppa?

My questions:

  1. Is simply “&” ignored when put before an array name?
    Are array names simply special on this?
  2. If so, how does the compiler verify that the identifier following “&” is a reference to an array? Does it actually search for it in a list of arrays so for declared?
  • 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-07T20:11:48+00:00Added an answer on June 7, 2026 at 8:11 pm

    Seems that &ar is taken as a pointer to the first element instead of a
    pointer to “ar”, which itself is a pointer to the pointer of the first
    element if I am not mistaken.

    You are mistaken. &ar is a pointer to the array ar, but the array ar is not a pointer of any sort (it’s an array), so &ar is not a pointer to a pointer.

    An array is a contiguous sequence of objects – in the case of ar, it’s a contiguous set of 4 chars. &ar is a pointer to this set of 4 chars, which necessarily means it points at the same place as &ar[0], a pointer to the first char in that set. It has a different type, though: &ar has type char (*)[4] which means “pointer to array of 4 chars” and &ar[0] has type char *, which means “pointer to char”.

    The confusion arises because in almost all expressions, ar evaluates to a pointer to the first element of the array (the exceptions to this are when it’s the operand of the unary & operator or the sizeof operator). This doesn’t mean that ar is a pointer though – it’s not – just that in most cases it evaluates to a pointer value.

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

Sidebar

Related Questions

First of all let me tell you that i have read the following questions
I recall when I first read Pragmatic Programmer that they suggested using scripting languages
I've read that by standard first part of e-mail is case sensitive, however I've
This is a very basic question on Java. I've read somewhere that at first
First I've read loads of posts and sites that recommend going to http://silverlight.net/GetStarted/ to
Why is it that both outs are printing 84? The first one should read
History: I read from one of Knuth's algorithm book that first computers used the
I want to open a text file (see below), read the first int in
This code loops forever: #include <iostream> #include <fstream> #include <sstream> int main(int argc, char
class Array { double *mx; int mn; public: Array(); ~Array(){delete []mx}; Array& operator-(Array& b);

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.