Data Structures
Algorithms
Interview Preparation
Topic-wise Practice
C++
Java
Python
Competitive Programming
Machine Learning
Web Development
Puzzles
Project Ideas
GFG School
Related Articles
Dangling, Void , Null and Wild Pointers
An Uncommon representation of array elements
How to declare a pointer to a function?
Pointer vs Array in C
void pointer in C / C++
NULL pointer in C
Function Pointer in C
What are near, far and huge pointers?
Generic Linked List in C
Linked List | Set 1 (Introduction)
Linked List | Set 2 (Inserting a node)
Linked List | Set 3 (Deleting a node)
Delete a Linked List node at a given position
Write a function to delete a Linked List
Find Length of a Linked List (Iterative and Recursive)
Search an element in a Linked List (Iterative and Recursive)
Write a function to get Nth node in a Linked List
Program for n’th node from the end of a Linked List
Find the middle of a given linked list
Write a function that counts the number of times a given int occurs in a Linked List
Detect loop in a linked list
Detect and Remove Loop in a Linked List
Add two numbers represented by linked lists | Set 1
Add two numbers represented by linked lists | Set 2
Add Two Numbers Represented by Linked Lists | Set 3
Arrays in C/C++
std::sort() in C++ STL
Dynamic Memory Allocation in C using malloc(), calloc(), free() and realloc()
Bitwise Operators in C/C++
What is Memory Leak? How can we avoid?
Pointer vs Array in C
Difficulty Level : Easy
Last Updated : 21 Oct, 2021
Most of the time, pointer and array accesses can be treated as acting the same, the major exceptions being:
1) the sizeof operator
o sizeof(array) returns the amount of memory used by all elements in array
o sizeof(pointer) only returns the amount of memory used by the pointer variable itself
2) the & operator
o array is an alias for &array[0] and returns the address of the first element in array
o &pointer returns the address of pointer
3) a string literal initialization of a character array
o char array[] = “abc” sets the first four elements in array to ‘a’, ‘b’, ‘c’, and ‘\0’
o char *pointer = “abc” sets pointer to the address of the “abc” string (which may be stored in read-only memory and thus unchangeable)
4) Pointer variable can be assigned a value whereas array variable cannot be.
p++; /*Legal*/a++; /*illegal*/