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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:38:40+00:00 2026-06-12T09:38:40+00:00

I see this question a lot on SO. Maybe not in so many words…

  • 0

I see this question a lot on SO. Maybe not in so many words… but time and again there is confusion on how arrays are different from pointers. So I thought I would take a moment to Q&A a few points about this.

For purposes of this Q&A we’re going to assume a 32-bit system and the following have been declared:

char * ptr = "hello";
char arr[10] = "hello";
int iarr[10] = {0};

Here’s a list of questions that surmise the confusion I see on SO. As I see new ones I’ll add to my list of Q&A (others feel free to as well, and correct me if you see any mistakes!)

  1. Isn’t a pointer and an array basically the same thing?
  2. Follow up: both *(ptr) and *(arr), or ptr[0] and arr[0] give the same thing, why?
  3. How come arr and &arr is the same value?
  4. Follow up: why do I get a different value printing arr+1 vs &arr+1?
  • 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-12T09:38:42+00:00Added an answer on June 12, 2026 at 9:38 am

    1) Pointers are not arrays. Arrays are not pointers. Don’t think of them that way because they are different.
    How can I prove this? Think about what they look like in memory:

    Our array arr is 10 characters long. It contains “Hello”, but wait, that’s not all! Because we have a statically declared array longer than our message, we get a bunch of NULL characters ('\0') thrown in for free! Also, note how the name arr is conceptually attached to the contiguous characters, (it’s not pointing to anything).
    enter image description here

    Next consider how our pointer would look in memory:
    enter image description here
    Note here we’re pointing to a character array some place in read only memory.

    So while both arr and ptr were initialized the same way, the contents/location of each is actually different.

    This is the key point:
    ptr is a variable, we can point it to anything, arr is a constant, it will always refer to this block of 10 characters.


    2) The [] is an “add and deference” operator that can be used on an address. Meaning that arr[0] is the same as saying *(arr+0). So yes doing this:

    printf("%c %c", *(arr+1), *(ptr+1));
    

    Would give you an output of “e e”. It’s not because arrays are pointers, it’s because the name of an array arr and a pointer ptr both happen to give you an address.

    Key point to #2: The deference operator * and the add and deference operator [] are not specific to pointers and arrays respectively. These operators simply work on addresses.


    3) I don’t have an extremely simple answer… so let’s forget our character arrays for a second and take a look at it this example for an explanation:

    int b;   //this is integer type
    &b;      //this is the address of the int b, right?
    
    int c[]; //this is the array of ints
    &c;      //this would be the address of the array, right?
    

    So that’s pretty understandable how about this:

    *c;   //that's the first element in the array
    

    What does that line of code tell you? If I deference c, then I get an int. That means just plain c is an address. Since it’s the start of the array it’s the address of the array and also the address of the first element in the array, thus from a value standpoint:

    c == &c;
    

    4) Let me go off topic for a second here… this last question is part of the confusion of address arithmetic. I saw a question on SO at one point implying that addresses are just integer values… You need to understand that in C addresses have knowledge of type. That is to say:

    iarr+1; //We added 1 to the address, so we moved 4 bytes
    arr+1;  //we added 1 to the address, so we moved 1 byte
    

    Basically the sizeof(int) is 4 and the sizeof(char) is 1. So “adding 1 to an array” is not as simple as it looks.

    So now, back to the question, why is arr+1 different from &arr+1? The first one is adding 1 * sizeof(char)=1 to the address, the second one is adding 1 * sizeof(arr)=10 to the address.

    This is why even though they are both “only adding 1” they give different results.

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

Sidebar

Related Questions

I see this question here on SO but I am not sure that answers
This question is famous but everyone always says go to see this Notepad Tutorial
I have a question, it's not the clearest but I wanted to see if
I know this type of question has been asked a lot, but I really
I know there are a lot of questions around this subject, but I cannot
I think this question was asked many times in C# but my problem is
This might sound like a trivial question to a lot of people, but since
See this question. How to show popup message like in stackoverflow I am trying
I wanted to use full import names in my project (see this question ).
So I see that this question has already been asked, however the answers were

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.