References and Dereferences | Pointers
C Basics

Зміст курсу

C Basics

# References and Dereferences

Pointers are built around two operators:

• The address-of operator `&`.
• The dereference operator `*`.

The address-of operator, represented by `&`, allows us to directly interact with our computer's RAM. Using `&` lets you obtain the actual memory address of an object.

Main

Note

`%p` is the format specifier used for addresses (pointer).

Think of the `&` operator as identifying your home's address using your name.

### Dereference Operator

Conversely, the `*` operator gives you the resident's name when given their address. So, how can we employ this operator if we're not directly dealing with addresses? If you have an expression like `&x`, which returns the address of the `x` variable, applying the `*` operator to it (`*&x`) gives you the value of the variable stored at that address.

Note

Essentially, `*&x` is the same as `x`.

Main

Note

Don't mix up the dereference operator (`*x`) with the multiplication operator (`x*y`).

Завдання

• Create an integer array of 5 elements and populate it.
• Retrieve the address of the third element.
• Increment the address of the third element (i.e., address + 1).
• Attempt to dereference the address obtained in the previous step.

Завдання

• Create an integer array of 5 elements and populate it.
• Retrieve the address of the third element.
• Increment the address of the third element (i.e., address + 1).
• Attempt to dereference the address obtained in the previous step.

Все було зрозуміло?

Секція 6. Розділ 2

# References and Dereferences

Pointers are built around two operators:

• The address-of operator `&`.
• The dereference operator `*`.

The address-of operator, represented by `&`, allows us to directly interact with our computer's RAM. Using `&` lets you obtain the actual memory address of an object.

Main

Note

`%p` is the format specifier used for addresses (pointer).

Think of the `&` operator as identifying your home's address using your name.

### Dereference Operator

Conversely, the `*` operator gives you the resident's name when given their address. So, how can we employ this operator if we're not directly dealing with addresses? If you have an expression like `&x`, which returns the address of the `x` variable, applying the `*` operator to it (`*&x`) gives you the value of the variable stored at that address.

Note

Essentially, `*&x` is the same as `x`.

Main

Note

Don't mix up the dereference operator (`*x`) with the multiplication operator (`x*y`).

Завдання

• Create an integer array of 5 elements and populate it.
• Retrieve the address of the third element.
• Increment the address of the third element (i.e., address + 1).
• Attempt to dereference the address obtained in the previous step.

Завдання

• Create an integer array of 5 elements and populate it.
• Retrieve the address of the third element.
• Increment the address of the third element (i.e., address + 1).
• Attempt to dereference the address obtained in the previous step.

Все було зрозуміло?

Секція 6. Розділ 2

# References and Dereferences

Pointers are built around two operators:

• The address-of operator `&`.
• The dereference operator `*`.

The address-of operator, represented by `&`, allows us to directly interact with our computer's RAM. Using `&` lets you obtain the actual memory address of an object.

Main

Note

`%p` is the format specifier used for addresses (pointer).

Think of the `&` operator as identifying your home's address using your name.

### Dereference Operator

Conversely, the `*` operator gives you the resident's name when given their address. So, how can we employ this operator if we're not directly dealing with addresses? If you have an expression like `&x`, which returns the address of the `x` variable, applying the `*` operator to it (`*&x`) gives you the value of the variable stored at that address.

Note

Essentially, `*&x` is the same as `x`.

Main

Note

Don't mix up the dereference operator (`*x`) with the multiplication operator (`x*y`).

Завдання

• Create an integer array of 5 elements and populate it.
• Retrieve the address of the third element.
• Increment the address of the third element (i.e., address + 1).
• Attempt to dereference the address obtained in the previous step.

Завдання

• Create an integer array of 5 elements and populate it.
• Retrieve the address of the third element.
• Increment the address of the third element (i.e., address + 1).
• Attempt to dereference the address obtained in the previous step.

Все було зрозуміло?

Pointers are built around two operators:

• The address-of operator `&`.
• The dereference operator `*`.

The address-of operator, represented by `&`, allows us to directly interact with our computer's RAM. Using `&` lets you obtain the actual memory address of an object.

Main

Note

`%p` is the format specifier used for addresses (pointer).

Think of the `&` operator as identifying your home's address using your name.

### Dereference Operator

Conversely, the `*` operator gives you the resident's name when given their address. So, how can we employ this operator if we're not directly dealing with addresses? If you have an expression like `&x`, which returns the address of the `x` variable, applying the `*` operator to it (`*&x`) gives you the value of the variable stored at that address.

Note

Essentially, `*&x` is the same as `x`.

Main

Note

Don't mix up the dereference operator (`*x`) with the multiplication operator (`x*y`).

Завдання

• Create an integer array of 5 elements and populate it.
• Retrieve the address of the third element.
• Increment the address of the third element (i.e., address + 1).
• Attempt to dereference the address obtained in the previous step.

Секція 6. Розділ 2
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?