C Academy · Lesson

Introduction to Pointers

Learn about pointers, memory addresses, dereferencing, and pointer arithmetic.

Lesson 1 of 310 steps

Introduction to Pointers is a free C Academy lesson on CoddyKit. This is lesson 1 of 3. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the C Academy learning path, and your progress syncs across the web and the CoddyKit app. The C Academy course includes 3 lessons in total.

Introduction to Pointers

Pointers are variables that store memory addresses instead of actual values.

In this lesson, you will learn:

  • What pointers are and how they work.
  • How to declare and initialize pointers.
  • How to use pointers to access memory.
Introduction to Pointers — illustration 1

Declaring a Pointer

A pointer is declared using the * operator.

Example:

int *ptr;

This creates a pointer variable ptr that can store the address of an integer.

Getting Memory Address

The & operator is used to get the memory address of a variable.

Example:

int num = 10; int *ptr = #

Here, ptr stores the address of num.

Dereferencing a Pointer

The * operator is used to access the value stored at a pointer's memory address.

Example:

int value = *ptr;

This retrieves the value stored at the memory address held by ptr.

Example: Using Pointers

This program demonstrates pointer declaration, initialization, and dereferencing.

#include <stdio.h>

int main() {
    int num = 42;
    int *ptr = &num;
    printf("Value of num: %d\n", num);
    printf("Memory address of num: %p\n", ptr);
    printf("Value accessed through pointer: %d\n", *ptr);
    return 0;
}

Pointer Arithmetic

Pointers can be used in arithmetic operations.

Example:

ptr++;

This moves the pointer to the next memory location.

Example: Pointer Arithmetic

This program demonstrates pointer arithmetic.

#include <stdio.h>

int main() {
    int arr[3] = {10, 20, 30};
    int *ptr = arr;
    printf("First element: %d\n", *ptr);
    ptr++;
    printf("Second element: %d\n", *ptr);
    return 0;
}

Advantages of Pointers

Pointers are useful for:

  • Efficient memory management.
  • Dynamic memory allocation.
  • Optimized data structures (linked lists, trees).

Summary

In this lesson, you learned:

  • How to declare and use pointers.
  • How to access memory addresses and values.
  • How to perform pointer arithmetic.

Next, we will explore dynamic memory allocation in C!

Introduction to Pointers — illustration 10
Free to start

Learn C with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
39
Lessons
144

Frequently Asked Questions

Is the “Introduction to Pointers” lesson free?

Yes — the full text of “Introduction to Pointers” is free to read here on the web. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the C Academy course, upgrade to CoddyKit PRO. The C Academy course includes 3 lessons in total.

What will I learn in “Introduction to Pointers”?

Learn about pointers, memory addresses, dereferencing, and pointer arithmetic. You practise C Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start C Academy?

No prior experience is required. C Academy on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 1 of 3.

How long does the “Introduction to Pointers” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this C Academy lesson?

Yes. Every C Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Introduction to Pointers
  2. Dynamic Memory Allocation
  3. Pointer Arrays and Function Pointers
← Back to C Academy