Here's a hypothetical memory map, showing the results of the two declarations:

                0x00  0x01  0x02  0x03  0x04  0x05  0x06  0x07
    0x00008000:  'n'   'o'   'w'   ' '   'i'   's'   ' '   't'
    0x00008008:  'h'   'e'   ' '   't'   'i'   'm'   'e'  '\0'
        ...
amessage:
    0x00500000:  'n'   'o'   'w'   ' '   'i'   's'   ' '   't'
    0x00500008:  'h'   'e'   ' '   't'   'i'   'm'   'e'  '\0'
pmessage:
    0x00500010:  0x00  0x00  0x80  0x00

The string literal "now is the time" is stored as a 16-element array of char at memory address 0x00008000. This memory may not be writable; it's best to assume that it's not. You should never attempt to modify the contents of a string literal.

The declaration

char amessage[] = "now is the time";

allocates a 16-element array of char at memory address 0x00500000 and copies the contents of the string literal to it. This memory is writable; you can change the contents of amessage to your heart's content:

strcpy(amessage, "the time is now");

The declaration

char *pmessage = "now is the time";

allocates a single pointer to char at memory address 0x00500010 and copies the address of the string literal to it.

Since pmessage points to the string literal, it should not be used as an argument to functions that need to modify the string contents:

strcpy(amessage, pmessage); /* OKAY */
strcpy(pmessage, amessage); /* NOT OKAY */
strtok(amessage, " ");      /* OKAY */
strtok(pmessage, " ");      /* NOT OKAY */
scanf("%15s", amessage);    /* OKAY */
scanf("%15s", pmessage);    /* NOT OKAY */

and so on. If you changed pmessage to point to amessage:

pmessage = amessage;

then it can be used everywhere amessage can be used.

Answer from John Bode on Stack Overflow
Top answer
1 of 14
176

Here's a hypothetical memory map, showing the results of the two declarations:

                0x00  0x01  0x02  0x03  0x04  0x05  0x06  0x07
    0x00008000:  'n'   'o'   'w'   ' '   'i'   's'   ' '   't'
    0x00008008:  'h'   'e'   ' '   't'   'i'   'm'   'e'  '\0'
        ...
amessage:
    0x00500000:  'n'   'o'   'w'   ' '   'i'   's'   ' '   't'
    0x00500008:  'h'   'e'   ' '   't'   'i'   'm'   'e'  '\0'
pmessage:
    0x00500010:  0x00  0x00  0x80  0x00

The string literal "now is the time" is stored as a 16-element array of char at memory address 0x00008000. This memory may not be writable; it's best to assume that it's not. You should never attempt to modify the contents of a string literal.

The declaration

char amessage[] = "now is the time";

allocates a 16-element array of char at memory address 0x00500000 and copies the contents of the string literal to it. This memory is writable; you can change the contents of amessage to your heart's content:

strcpy(amessage, "the time is now");

The declaration

char *pmessage = "now is the time";

allocates a single pointer to char at memory address 0x00500010 and copies the address of the string literal to it.

Since pmessage points to the string literal, it should not be used as an argument to functions that need to modify the string contents:

strcpy(amessage, pmessage); /* OKAY */
strcpy(pmessage, amessage); /* NOT OKAY */
strtok(amessage, " ");      /* OKAY */
strtok(pmessage, " ");      /* NOT OKAY */
scanf("%15s", amessage);    /* OKAY */
scanf("%15s", pmessage);    /* NOT OKAY */

and so on. If you changed pmessage to point to amessage:

pmessage = amessage;

then it can be used everywhere amessage can be used.

2 of 14
120

True, but it's a subtle difference. Essentially, the former:

char amessage[] = "now is the time";

Defines an array whose members live in the current scope's stack space, whereas:

char *pmessage = "now is the time";

Defines a pointer that lives in the current scope's stack space, but that references memory elsewhere (in this one, "now is the time" is stored elsewhere in memory, commonly a string table).

Also, note that because the data belonging to the second definition (the explicit pointer) is not stored in the current scope's stack space, it is unspecified exactly where it will be stored and should not be modified.

As pointed out by Mark, GMan, and Pavel, there is also a difference when the address-of operator is used on either of these variables. For instance, &pmessage returns a pointer of type char**, or a pointer to a pointer to chars, whereas &amessage returns a pointer of type char(*)[16], or a pointer to an array of 16 chars (which, like a char**, needs to be dereferenced twice as litb points out).

🌐
GeeksforGeeks
geeksforgeeks.org › c language › difference-between-array-and-pointers
Difference between Arrays and Pointers - GeeksforGeeks
July 23, 2025 - When Arrays are created the fixed size of the memory block is allocated. But with Pointers the memory is dynamically allocated. There are some other differences between an array and a pointer which are discussed below in the table.
Discussions

What is the difference between an array and a pointer in C, and when should I use one over the other? - Stack Overflow
I am a first-year CSE student, and I’m currently learning C programming. I understand the basics of arrays and pointers, but I’m still a bit confused about the key differences between them and when... More on stackoverflow.com
🌐 stackoverflow.com
In c, what is the difference between char *, char **, and char ***?
  • A char * is a pointer to a char. The value stored in a char * is a memory address, and the value stored at that memory address is a char.

  • A char ** is a pointer to a pointer to a char; it's a pointer to a char *. The value stored in a char ** is a memory address, and the value stored at that memory address is a char *.

  • A char *** is a pointer to a pointer to a pointer to a char; it's a pointer to a char **. The value stored in a char *** is a memory address, and the value stored at that memory address is a char **.

More on reddit.com
🌐 r/learnprogramming
15
4
April 5, 2014
Difference between pointer to pointer and 2d array
A 2D array in C is pretty much equal to 1D array, which is just indexed differently, in code: int foo[10][10]; foo[5][5]; int bar[10 * 10]; bar[5 * 10 + 5]; The foo and bar usages are in essence equal. A int ** expects a pointer to pointer, but the pointer simply does not exists in a "2D" array. What you need is pointer to array int (*arr)[width]. To add more fun to your original pondering on a == *a, also a == &a. Only the types differ. a is char (*)[1], *a is char *, and &a is char (*)[1][1]. More on reddit.com
🌐 r/C_Programming
9
0
August 12, 2023
Difference between char * and char[]?
The main difference is that there is no array assignment operator while pointers have one. That’s because an array assignment would actually be an array copy operation. And sizeof behaves differently on both of them. sizeof(char*) is the size of a pointer while sizeof(char[n]) is sizeof(char) x n (x is multiplication as a star may cause bad formatting). When assigning a string literal to a pointer you get the address pointing to the rdatq area of the mapped image where the string literal is stored with the zero terminator. When assigning it to an array the array has the size of the string literal plus the zero terminator. More on reddit.com
🌐 r/C_Programming
27
77
October 28, 2020
People also ask

Is an array a pointer in C?
No, but the array name acts like a pointer to its first element in many contexts.
🌐
wscubetech.com
wscubetech.com › resources › c-programming › difference-between-pointer-and-array
Difference Between Pointer and Array in C (With Example)
Which is faster: pointer or array in C?
Performance is generally the same, but pointers can be more efficient in dynamic scenarios or when used in loops.
🌐
wscubetech.com
wscubetech.com › resources › c-programming › difference-between-pointer-and-array
Difference Between Pointer and Array in C (With Example)
Can we assign an array to a pointer in C?
Yes. For example: int *ptr = arr; assigns the base address of the array to the pointer.
🌐
wscubetech.com
wscubetech.com › resources › c-programming › difference-between-pointer-and-array
Difference Between Pointer and Array in C (With Example)
🌐
Reddit
reddit.com › r/c_programming › what exactly is the difference between a pointer and an array?
r/C_Programming on Reddit: What exactly is the difference between a pointer and an array?
July 16, 2020 -

Any video I watch, or any article I read, I always see arrays being referred to as "pointers", or the phrase, "an array is a pointer in itself". I know that we can represent arrays in a pointer-like fashion and that &array-name[0] is the address of the 0th element or in essence, the starting address of the array. But can we call an array a pointer? If my memory serves right, whenever we create pointers, the are allocated memory from the heap memory instead of the stack memory and it is exactly opposite for static arrays.

If so, then why do people refer to arrays as pointers many times? I read this answer on StackOverflow and it seemed pretty valid to me yet I do not get it why are the above phrases/jargon used by people?

Could I please get some explanation on this and some clarification on this topic? It would be of much help. This whole thing is bugging me for the last 4-5 days.

Thank you :)

Top answer
1 of 3
12
With me it helped that I spent several years writing games in assembly language where the concept of an array doesn't really exist. Everything is just bytes in RAM. A pointer holds an address. From the CPU's point of view it is just the address of an area in memory. There is no concept of arrays at this level just a large number of bytes at sequential addresses. When you move into C though, the compiler needs to know things. If it's a pointer, what type of data is at the address that the pointer holds? If it's an an int e.g. int * ptr then the four bytes at address, address+1,address+2,address+3 are what *ptr refer to. An array is just a repeating length of bytes held at an address in memory. If you have an array of int e.g. int fred[10] is just a block of forty consecutive bytes. You can think as fred as being the address of this block, and ptr = fred just means set ptr = the address of fred. We can also set ptr to point to any of the 10 ints held in fred. ptr = &fred[0], or &freed[9]. The compiler just calculates the index offset say 9, multiplies it by the size of int (4) and adds it to the address of fred. So ptr now has the address fred + 36. *ptr is the int that is stored at addresses fred+36,37,38 and 39. All of the RAM that is not used by the stack or global variables is as you said the heap. You have to reserve a chunk of it with malloc which returns a pointer to your reserved block before you can use it and when you are finished with it, you must free it. Because malloc just returns a bare pointer, you have to tell the C compiler what type to use with it by casting. There's nothing magical about arrays and pointers. They are just 'structures' superimposed on RAM for the purpose of using them.
2 of 3
3
An array is different from a pointer mainly due to the fact that its size is encoded in its type. If you write, int foo[5]; printf("%d", sizeof(foo)); it will print 20 on most modern systems, where ints are 4 bytes. The confusion about the duality of arrays and pointers mostly arises due to something called array/pointer decay, which is a property of C that causes arrays to "decay" (i.e. something is lost, in this case information about its length) to a pointer. Whenever you pass an array to a function or return one (which you should never do anyway), this is what happens. It decays to a pointer, meaning the callee has no information about its size. void print_size(int* array) { printf("argument size: %d", sizeof(array)); } int foo[5] = { 1, 2, 3, 4, 5 }; printf("\nsize: %d ", sizeof(foo)); print_size(foo); // decay to pointer This will print, size: 20 argument size: 8 8 is the size of a pointer on any modern, 64-bit system. The function has no way of determining how many elements the array has. Since, as you said, the identifier of an array merely points to its first element, you could also do, int a = 123; // not an array print_size(&a); and it would work perfectly fine. The general solution for this issue is to add another parameter that asks for the number of elements in the array you passed as a pointer. void print_array(int* array, size_t size) { for (size_t i = 0; i < size; ++i) { printf("%d ", array[i]); } } int foo[] = { 1, 2, 3, 4, 5 }; print_array(foo, 5); // decay to pointer // or, without hardcoding the size argument print_array(foo, sizeof(foo) / sizeof(int));// again, decay to pointer You might be wondering how print_array can use its array parameter as if it were an array, even though it's a pointer. This is where pointer arithmetic comes in. Remember, in array decay, the array becomes a pointer to its first element. The authors of the language thought of this and allowed using pointers as arrays. If you say, pointer[index] = 234; the product of index and the size of the type of the data pointer points to is added to the address pointer represents, and the whole result is dereferenced. This may sound complicated, but in a simplified way, it means that working with pointers is the same as working with arrays. It's as if you had written, *(pointer + index) = 234; The two aren't just similar, they're exactly equivalent. Since addition is commutative, i.e. the order of the operands doesn't matter, you could also swap them, like this, 4[array] = 234; instead of, array[4] = 234; This compiles, and it is legal, but it looks silly, so no one does it. I hope this provides some insight.
🌐
TutorialsPoint
tutorialspoint.com › difference-between-array-and-pointer
Difference Between Array and Pointer
February 20, 2023 - To differentiate from the target variable type, the name of the pointer is prefixed with an asterisk (*). If we have an int variable, its pointer is declared as "int *". ... Note: In case of an array, the address of its 0th element is assigned to the pointer. ... In fact, the name of the array itself resolves to the address of the 0th element. ... Since the elements of an array are placed in adjacent memory locations and the address of each subscript increments by 4 (in case of an int array), we can use this feature to traverse the array elements with the help of pointer as well.
🌐
Programiz
programiz.com › c-programming › c-pointers-arrays
Relationship Between Arrays and Pointers in C Programming (With Examples)
To access elements of the array, we have used pointers. In most contexts, array names decay to pointers. In simple words, array names are converted to pointers. That's the reason why you can use pointers to access elements of arrays.
🌐
TutorialsPoint
tutorialspoint.com › cprogramming › c_pointer_vs_array.htm
Pointer vs Array in C
To differentiate from the target variable type, the name of the pointer is prefixed with an asterisk (*). If we have an int variable, its pointer is declared as "int *". ... Note: In case of an array, the address of its 0th element is assigned to the pointer. ... In fact, the name of the array itself resolves to the address of the 0th element. ... Since the elements of an array are placed in adjacent memory locations and the address of each subscript increments by 4 (in case of an int array), we can use this feature to traverse the array elements with the help of pointer as well.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › c language › pointer-vs-array-in-c
Pointer vs Array in C - GeeksforGeeks
char *pointer = “abc” sets ... p++; /*Legal*/ a++; /*illegal*/ 6. Array is a collection of similar data types while the pointer variable stores the address of another variable....
Published   July 23, 2025
🌐
Carleton University
people.scs.carleton.ca › ~mjhinek › W13 › COMP2401 › notes › Arrays_and_Pointers.pdf pdf
T h e G r o u p o f T h r e e 2013 Arrays and Pointers Class Notes
So A can be considered a const int*. Since A is a constant pointer, A = NULL · would be an illegal statement. Arrays and pointers are synonymous in terms of how they use to access · memory. But, the important difference between them is that, a pointer variable can take different
🌐
WsCube Tech
wscubetech.com › resources › c-programming › difference-between-pointer-and-array
Difference Between Pointer and Array in C (With Example)
March 17, 2026 - Learn in this tutorial about pointers vs arrays in C with differences, similarities, and examples. Understand their use cases and when to use each in C program.
🌐
Aticleworld
aticleworld.com › home › difference between pointer and array in c?
Difference between pointer and array in C? - Aticleworld
October 1, 2020 - Here we see difference between pointer and array in C. Array is collection of elements of similar data types whereas pointer is variable that store address.
🌐
O'Reilly
oreilly.com › library › view › understanding-and-using › 9781449344535 › ch04.html
4. Pointers and Arrays - Understanding and Using C Pointers [Book]
May 8, 2013 - An array name is not a pointer. Although an array name can be treated as a pointer at times, and array notation can be used with pointers, they are distinct and cannot always be used in place of each other.
Author   Richard M Reese
Published   2013
Pages   223
Top answer
1 of 1
5
  • An array is a contiguous block of memory that holds its elements.
  • A pointer is an object that stores the address of the first element of an array. The pointer does not hold any information about whether it points to a single object (which can be considered an array with just one element) or an actual array with multiple elements

When arrays are used in expressions they decay1 to pointers. In C, array-to-pointer decay refers to the automatic conversion of an array's name to a pointer to its first element. This decay happens in most contexts where an array is used, making the array's name behave like a pointer.

There are a few places when array do not decay to poointers:

  • when using the sizeof operator
  • when using the address-of operator (&)

Can you clarify how memory management works in both cases? I’ve heard that arrays have a fixed size in memory, whereas pointers can be used more flexibly, but I’m still not fully understanding when this flexibility is beneficial.

Aspect Arrays Dynamic Memory Allocation
Memory Lifetime Automatic (based on scope) Manual (requires free())
Size Determination Fixed at compile time (some compilers support Variable Length Arrays), the size cant be changed Flexible, decided at runtime, resizeable
Allocation Timing At declaration At runtime (malloc(), etc.)
Deallocation Automatic (when the scope ends) Manual (free())
Resizability Not resizable Resizable (realloc())
Initialization Can be initialized at declaration Must be initialized manually
Access Speed Typically faster (direct access) Potentially slower (indirect access)
Risk of Memory Leaks None (automatic management) Yes (if free() is missed)
Data Persistence Limited to the scope of declaration Can persist beyond function scope
Potential Issues Size limits based on declaration context, Cant be used when out of scope Risk of memory leaks, dangling and wild pointers etc

1 Decay: The term "decay" is a modern, informal term commonly used in the programming community to describe the process outlined in the C standard: "Except when it is the operand of the sizeof operator, the unary & operator, or is a string literal used to initialize an array, an expression of type 'array of T' is converted to an expression of type 'pointer to T' that points to the initial element of the array object."*

🌐
W3Schools
w3schools.com › c › c_pointers_arrays.php
C Pointers and Arrays
This basically means that we can work with arrays through pointers! How? Since myNumbers is a pointer to the first element in myNumbers, you can use the * operator to access it:
🌐
GeeksforGeeks
geeksforgeeks.org › c language › difference-between-array-and-pointers
Difference between pointer and array in C?
July 23, 2025 - When Arrays are created the fixed size of the memory block is allocated. But with Pointers the memory is dynamically allocated. There are some other differences between an array and a pointer which are discussed below in the table.
🌐
Shiksha
shiksha.com › home › it & software › it & software articles › programming articles › difference between array and pointer
Difference Between Array and Pointer
March 28, 2024 - An array is a fixed-size collection of elements of the same type stored in contiguous memory locations, while a pointer is a variable that stores the memory address of another variable.
🌐
Eli Bendersky
eli.thegreenplace.net › 2009 › 10 › 21 › are-pointers-and-arrays-equivalent-in-c
Are pointers and arrays equivalent in C? - Eli Bendersky's website
One way is that arrays just can't be manipulated the way pointers can. Here's a quote from Expert C Programming: There is one difference between an array name and a pointer that must be kept in mind. A pointer is a variable, so pa=a and pa++ are legal.
🌐
Tech Differences
techdifferences.com › home › difference between array and pointer
Difference Between Array and Pointer (with Comparison Chart) - Tech Differences
October 21, 2022 - The basic difference between an array and a pointer is that, an array is a collection of variables of similar data type whereas the pointer is a variable that stores the address of another variable.
🌐
Holy City Sinner
holycitysinner.com › entertainment › arrays-vs.-pointers-clarifying-relationship-differences
Arrays vs. Pointers: Clarifying the Relationship and Differences - Holy City Sinner
October 29, 2023 - Now that we’ve explored the basics, let’s highlight the key differences between arrays and pointers: ... Arrays have a fixed size determined at compile-time. Once an array is created, its size cannot be changed.
🌐
Quora
quora.com › What-is-the-difference-between-pointers-and-arrays-in-C-Why-are-pointers-commonly-used-instead-of-arrays
What is the difference between pointers and arrays in C? Why are pointers commonly used instead of arrays? - Quora
Otherwise you would not be asking the question. An array is a collection of data objects all of the same type located contiguously in memory. A pointer is a single data object that references (that is, “points ...