Pointers & ArraysBeginner
1Question 1 of 1
cWhat is the difference between Pointers and Arrays in C?
Explanation & Concept
• Array: A contiguous block of memory with a fixed size. The array identifier acts as a constant pointer to its first element (`arr == &arr[0]`), but you cannot reassign it (`arr = ptr` is invalid). • Pointer: A variable that stores the memory address of another variable. Pointers can be reassigned and incremented using pointer arithmetic.
Code Example
c
#include <stdio.h>
int main() {
int numbers[3] = {10, 20, 30};
int *ptr = numbers; // Decays to pointer to first element
printf("First: %d\n", *ptr); // 10
printf("Second: %d\n", *(ptr + 1)); // 20 (Pointer arithmetic advances by sizeof(int))
return 0;
}How It Works & Key Takeaways
Pointer arithmetic automatically scales offsets by the byte size of the underlying type (`sizeof(T)`).
Mock Test · 1 Questions · Optional
Ready for Memory Management?
Take a quick test to evaluate yourself, or move straight to the next module.
Beginner3 questions