- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
Swapping values using pointers in C Programming Language
In this short video I explain how we can use pointers to swap non-local variables.
Additional information about pointers in C:
* Pointers also allow us to access and modify variables in the Stack, HEAP, and Data Segment of the Memory. We can only read from the Code Segment of the Memory, therefore we can declare pointers that point to the Code Segment but not change the values.
Declaring and initializing a pointer to an integer:
int *p = &x; ( read as "p (pointer) points to an integer x, p holds the address of the integer x)
or
int *p;
p = &x;
Modifying the value that p points to using only the pointer:
*p = 4; ( dereference p (follow where p points to and change that variable to 4), now x is going to be equal to 4)
Checking the value that p points to:
printf("%d \n", *p);
Useful tip:
Understand the problem by drawing a diagram and solving the problem on paper, before starting to write the code. (It will save you a headache :D)
Видео Swapping values using pointers in C Programming Language канала Camerie Mazreku
Additional information about pointers in C:
* Pointers also allow us to access and modify variables in the Stack, HEAP, and Data Segment of the Memory. We can only read from the Code Segment of the Memory, therefore we can declare pointers that point to the Code Segment but not change the values.
Declaring and initializing a pointer to an integer:
int *p = &x; ( read as "p (pointer) points to an integer x, p holds the address of the integer x)
or
int *p;
p = &x;
Modifying the value that p points to using only the pointer:
*p = 4; ( dereference p (follow where p points to and change that variable to 4), now x is going to be equal to 4)
Checking the value that p points to:
printf("%d \n", *p);
Useful tip:
Understand the problem by drawing a diagram and solving the problem on paper, before starting to write the code. (It will save you a headache :D)
Видео Swapping values using pointers in C Programming Language канала Camerie Mazreku
Комментарии отсутствуют
Информация о видео
10 ноября 2022 г. 2:08:36
00:03:00
Другие видео канала
