Arrays, Strings, and Pointer Basics
Move into one of the most important areas of C by learning arrays, string representation, addresses, and pointer fundamentals.
Inside this chapter
- Arrays
- Strings in C
- Pointers
- Array and Pointer Relationship
- Common Mistakes
- Real-World Usage Snapshot
Series navigation
Study the chapters in order for the clearest path from C basics to advanced memory, systems, debugging, and real-world development practice. Use the navigation at the bottom of each page to move smoothly through the full tutorial.
Arrays
int numbers[5] = {10, 20, 30, 40, 50};
printf("%d\n", numbers[0]);
Arrays store elements contiguously in memory. Indexing starts at zero. C does not perform automatic bounds checking, so accessing outside the array is dangerous and causes undefined behavior.
Strings in C
A string in C is an array of characters terminated by the null character '\0'.
char name[] = "Alice";
printf("%s\n", name);
Students must remember that strings are not a built-in high-level type in C. They are character arrays with conventions.
Pointers
int x = 10;
int *ptr = &x;
printf("%d\n", *ptr);
ptr stores the address of x. Dereferencing with *ptr accesses the value at that address. This is one of the most important skills in C and one of the most common places beginners feel confused at first.
Array and Pointer Relationship
Arrays and pointers are closely related in C, though they are not identical. In many expressions, the array name behaves like a pointer to its first element. This explains why pointer arithmetic and array indexing are deeply connected.
Common Mistakes
- Forgetting space for the null terminator in strings
- Dereferencing uninitialized pointers
- Confusing the address of a variable with its value
- Reading or writing beyond array bounds
Real-World Usage Snapshot
Arrays and pointers are used everywhere in C: buffers, network packets, image processing, text parsing, matrix operations, and dynamic data structures. Getting these basics right is essential for every advanced topic that follows.