Free tutorials & notes in Hindi & English · Clean code examples · Mobile friendly learning
Free tutorials in Hindi & English Daily computer, mobile and IT guides Beginner friendly learning
Blog · C Pointers · 03 Jul 2026 · Hindi + English

C में Array और Pointer में अंतर (Table के साथ)

Arrays और pointers similar दिखते हैं लेकिन sizeof, assignment, memory और behaviour में अलग हैं. पूरी comparison table और famous sizeof proof program.

Why the confusion exists

Arrays and pointers feel identical because in most expressions an array name decays into a pointer to its first element: arr becomes &arr[0], and arr[i] equals *(arr + i). But an array is not a pointer — and 4 differences prove it.

Difference 1: sizeof (the famous proof)

#include <stdio.h>

int main() {
    int arr[5] = {1, 2, 3, 4, 5};
    int *p = arr;

    printf("sizeof(arr) = %zu\n", sizeof(arr));  /* 20: whole array   */
    printf("sizeof(p)   = %zu\n", sizeof(p));    /* 8: just a pointer */
    return 0;
}
sizeof(arr) = 20 sizeof(p) = 8

sizeof sees the truth: arr is a 20-byte block of 5 ints; p is an 8-byte address holder. If arrays were pointers, both would print 8.

Difference 2: Assignment

int arr[5], brr[5];
int *p, *q;

p = q;        /* OK: pointers can be reassigned         */
p = arr;      /* OK: array decays to pointer            */
arr = brr;    /* ERROR: array name is not modifiable    */
arr++;        /* ERROR: cannot move an array            */

A pointer is a variable — it can point anywhere, any time. An array name is a fixed label for a fixed block of memory; it can never be reassigned or incremented.

Difference 3: Memory

  • Array: one allocation — the elements themselves. There is no separate "arr variable" storing an address.
  • Pointer: its own memory (8 bytes) that stores an address, separate from whatever it points to.

Difference 4: Behaviour with strings

char arr[] = "hello";   /* modifiable copy in the array   */
char *p    = "hello";   /* points to read-only literal    */

arr[0] = 'H';           /* OK                             */
p[0]   = 'H';           /* CRASH: undefined behaviour     */
This is the most practical difference and a top interview trap: string literals live in read-only memory, so writing through a char* to a literal crashes, while a char array holds its own writable copy.

Complete comparison table

PointArrayPointer
sizeofTotal bytes of all elementsSize of an address (4/8 bytes)
ReassignmentImpossibleAny time
arr++ / p++ErrorValid
MemoryBlock of elements onlySeparate 8-byte address holder
&nameAddress of whole array (int (*)[5])Address of the pointer variable
String literal initWritable copyRead-only reference

Confusion क्यों होता है

Arrays और pointers identical लगते हैं क्योंकि ज़्यादातर expressions में array name अपने पहले element के pointer में decay हो जाता है: arr बन जाता है &arr[0], और arr[i] = *(arr + i). लेकिन array pointer नहीं है — और 4 अंतर इसे prove करते हैं.

अंतर 1: sizeof (famous proof)

#include <stdio.h>

int main() {
    int arr[5] = {1, 2, 3, 4, 5};
    int *p = arr;

    printf("sizeof(arr) = %zu\n", sizeof(arr));  /* 20: पूरा array    */
    printf("sizeof(p)   = %zu\n", sizeof(p));    /* 8: सिर्फ pointer  */
    return 0;
}
sizeof(arr) = 20 sizeof(p) = 8

sizeof सच दिखाता है: arr पांच ints का 20-byte block है; p आठ-byte का address holder. अगर arrays pointers होते, तो दोनों 8 print करते.

अंतर 2: Assignment

int arr[5], brr[5];
int *p, *q;

p = q;        /* OK: pointers reassign हो सकते हैं       */
p = arr;      /* OK: array pointer में decay होता है     */
arr = brr;    /* ERROR: array name modifiable नहीं है    */
arr++;        /* ERROR: array को move नहीं कर सकते       */

Pointer एक variable है — कभी भी, कहीं भी point कर सकता है. Array name memory के fixed block का fixed label है; कभी reassign या increment नहीं हो सकता.

अंतर 3: Memory

  • Array: एक allocation — खुद elements. कोई अलग "arr variable" नहीं जो address store करे.
  • Pointer: अपनी memory (8 bytes) जो address store करती है, उससे अलग जिसे वह point करता है.

अंतर 4: Strings के साथ behaviour

char arr[] = "hello";   /* array में modifiable copy       */
char *p    = "hello";   /* read-only literal को point करता */

arr[0] = 'H';           /* OK                              */
p[0]   = 'H';           /* CRASH: undefined behaviour      */
यह सबसे practical अंतर और top interview trap है: string literals read-only memory में रहते हैं, इसलिए char* से literal पर लिखना crash करता है, जबकि char array अपनी writable copy रखता है.

पूरी comparison table

PointArrayPointer
sizeofसभी elements के total bytesAddress का size (4/8 bytes)
ReassignmentImpossibleकभी भी
arr++ / p++ErrorValid
Memoryसिर्फ elements का blockअलग 8-byte address holder
&nameपूरे array का address (int (*)[5])Pointer variable का address
String literal initWritable copyRead-only reference

Frequently Asked Questions

क्या C में array name pointer है?

नहीं. Array name ज़्यादातर expressions में पहले element के pointer में decay होता है, लेकिन sizeof, & और reassign न हो पाना साबित करते हैं कि यह अलग array type है.

sizeof(arr) और sizeof(p) अलग क्यों होते हैं?

sizeof(arr) सभी elements के total bytes देता है (int[5] के लिए 20), जबकि sizeof(p) सिर्फ address का size देता है (64-bit पर 8 bytes).

char *p = "hello"; p[0]='H'; crash क्यों करता है?

String literal read-only memory में रहता है; pointer से उस पर लिखना undefined behaviour है. Literal से initialize हुआ char array इसके बजाय writable copy रखता है.