Unit III: Arrays and Pointers

Table of Contents

1. Array Processing and Strings

An array is a collection of elements of the same type stored in contiguous memory locations.


2. Pointer Fundamentals

A pointer is a variable that stores the memory address of another variable.


3. Address Arithmetic

Address arithmetic refers to the operations that can be performed on pointers.

Rule: When you increment a pointer, it moves forward by the size of the data type it points to (e.g., +4 bytes for an int pointer on most systems).

4. Pointers vs Multidimensional Arrays

There is a strong relationship between pointers and multidimensional arrays in C.


5. Command Line Arguments & Function Pointers

Advanced pointer usage allows for dynamic and highly flexible programming.

Exam Tips


Frequently Asked Questions

Q: What is the difference between char a[] = "hello" and char *p = "hello"?
The first is an array that can be modified. The second is a pointer to a string literal, which is often stored in read-only memory and should not be modified.

Q: What is 'argc' and 'argv'?
'argc' (argument count) is the number of strings on the command line, and 'argv' (argument vector) is an array of pointers to those strings.