Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Pointers Brief Overview | Pointers and Structs
C Structs
course content

Зміст курсу

C Structs

C Structs

1. Introduction to Structs
2. Pointers and Structs
3. Structs and Memory
4. Advanced Structs Usage
5. Implementing Data Structures

bookPointers Brief Overview

To go through the following chapters, I suggest briefly repeating the pointers in the C programming language.

Note

If you are not familiar with the basic skills of working with the C programming language, we recommend taking our basic C programming language course: C Basic

Dereferencing Operator

A pointer is a variable that contains the address of another object.

Dereference operator "*" returns the value stored at the address.

Declaring and initializing a pointer looks like this:

c

main

copy
12345678
#include <stdio.h> int main() { int* pName = NULL; printf("%p\n", pName); // `%p` is a specifier for a pointer return 0; }

Referencing Operator &

The "&" operator returns the address of an object:

c

main

copy
12345678
#include <stdio.h> int main() { int variable; printf("%p\n", &variable); return 0; }

A variable of pointer type is used to store the address, which is returned by the & operator.

To "unpack" the contents at the specified address, you must use the * operator on a variable of type pointer.

c

main

copy
12345678910
#include <stdio.h> int main() { int variable = 1024; int* pVariable = &variable; printf("Address: %p\n", pVariable); // `%p` specifier for a pointer printf("Returned value by address: %d\n", *(pVariable)); // using `*` to pointer return 0; }

Завдання

  1. Declare and initialize any variable with any value;
  2. Declare a pointer to the same data type as your variable;
  3. Assign the address of a variable to a pointer;
  4. Display an address of your variable;
  5. Display the value of the variable by the pointer.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 1
toggle bottom row

bookPointers Brief Overview

To go through the following chapters, I suggest briefly repeating the pointers in the C programming language.

Note

If you are not familiar with the basic skills of working with the C programming language, we recommend taking our basic C programming language course: C Basic

Dereferencing Operator

A pointer is a variable that contains the address of another object.

Dereference operator "*" returns the value stored at the address.

Declaring and initializing a pointer looks like this:

c

main

copy
12345678
#include <stdio.h> int main() { int* pName = NULL; printf("%p\n", pName); // `%p` is a specifier for a pointer return 0; }

Referencing Operator &

The "&" operator returns the address of an object:

c

main

copy
12345678
#include <stdio.h> int main() { int variable; printf("%p\n", &variable); return 0; }

A variable of pointer type is used to store the address, which is returned by the & operator.

To "unpack" the contents at the specified address, you must use the * operator on a variable of type pointer.

c

main

copy
12345678910
#include <stdio.h> int main() { int variable = 1024; int* pVariable = &variable; printf("Address: %p\n", pVariable); // `%p` specifier for a pointer printf("Returned value by address: %d\n", *(pVariable)); // using `*` to pointer return 0; }

Завдання

  1. Declare and initialize any variable with any value;
  2. Declare a pointer to the same data type as your variable;
  3. Assign the address of a variable to a pointer;
  4. Display an address of your variable;
  5. Display the value of the variable by the pointer.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 1
toggle bottom row

bookPointers Brief Overview

To go through the following chapters, I suggest briefly repeating the pointers in the C programming language.

Note

If you are not familiar with the basic skills of working with the C programming language, we recommend taking our basic C programming language course: C Basic

Dereferencing Operator

A pointer is a variable that contains the address of another object.

Dereference operator "*" returns the value stored at the address.

Declaring and initializing a pointer looks like this:

c

main

copy
12345678
#include <stdio.h> int main() { int* pName = NULL; printf("%p\n", pName); // `%p` is a specifier for a pointer return 0; }

Referencing Operator &

The "&" operator returns the address of an object:

c

main

copy
12345678
#include <stdio.h> int main() { int variable; printf("%p\n", &variable); return 0; }

A variable of pointer type is used to store the address, which is returned by the & operator.

To "unpack" the contents at the specified address, you must use the * operator on a variable of type pointer.

c

main

copy
12345678910
#include <stdio.h> int main() { int variable = 1024; int* pVariable = &variable; printf("Address: %p\n", pVariable); // `%p` specifier for a pointer printf("Returned value by address: %d\n", *(pVariable)); // using `*` to pointer return 0; }

Завдання

  1. Declare and initialize any variable with any value;
  2. Declare a pointer to the same data type as your variable;
  3. Assign the address of a variable to a pointer;
  4. Display an address of your variable;
  5. Display the value of the variable by the pointer.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

To go through the following chapters, I suggest briefly repeating the pointers in the C programming language.

Note

If you are not familiar with the basic skills of working with the C programming language, we recommend taking our basic C programming language course: C Basic

Dereferencing Operator

A pointer is a variable that contains the address of another object.

Dereference operator "*" returns the value stored at the address.

Declaring and initializing a pointer looks like this:

c

main

copy
12345678
#include <stdio.h> int main() { int* pName = NULL; printf("%p\n", pName); // `%p` is a specifier for a pointer return 0; }

Referencing Operator &

The "&" operator returns the address of an object:

c

main

copy
12345678
#include <stdio.h> int main() { int variable; printf("%p\n", &variable); return 0; }

A variable of pointer type is used to store the address, which is returned by the & operator.

To "unpack" the contents at the specified address, you must use the * operator on a variable of type pointer.

c

main

copy
12345678910
#include <stdio.h> int main() { int variable = 1024; int* pVariable = &variable; printf("Address: %p\n", pVariable); // `%p` specifier for a pointer printf("Returned value by address: %d\n", *(pVariable)); // using `*` to pointer return 0; }

Завдання

  1. Declare and initialize any variable with any value;
  2. Declare a pointer to the same data type as your variable;
  3. Assign the address of a variable to a pointer;
  4. Display an address of your variable;
  5. Display the value of the variable by the pointer.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 2. Розділ 1
Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
some-alt