Returning Pointers from Functions -- C++ Pointers Tutorial [9]

  Рет қаралды 5,184

Professor Hank Stalica

Professor Hank Stalica

Күн бұрын

Пікірлер: 16
@leythecg
@leythecg Жыл бұрын
Short and to the point (Pointer ;-) Thank you! Your videos are true jewels!
@ProfessorHankStalica
@ProfessorHankStalica Жыл бұрын
Glad you like them!
@qcnck2776
@qcnck2776 Жыл бұрын
Thanks for a nice explanation of the pitfalls of 'delete'
@ProfessorHankStalica
@ProfessorHankStalica Жыл бұрын
You're welcome
@yazanallahham4813
@yazanallahham4813 Жыл бұрын
at minute 4:10, why does it return "talica" ? why does it not return the memory address of "t" in the array of characters ? I thought if we made return type char*, and put return p in the function, it should return the memory address. Pls clarify, thxxx very helpful tutorials
@ProfessorHankStalica
@ProfessorHankStalica Жыл бұрын
It does. cout starts displaying characters, one at a time, from the memory address you give it until it encounters the null terminator. So, in this case, we returned the memory address of the element containing t instead of the memory address of the element containing s.
@makaty9883
@makaty9883 7 ай бұрын
thx for the valuable content!
@chiyang3749
@chiyang3749 8 ай бұрын
in cout, the ptr should print the memory address of that character, but why it print the actual character?
@mohamedboubakeur4554
@mohamedboubakeur4554 7 ай бұрын
listen to what he said (3:44)
@liboyan7010
@liboyan7010 Жыл бұрын
good to know, thanks a lot!!!
@ProfessorHankStalica
@ProfessorHankStalica Жыл бұрын
Happy to help!
@sameaspastmueed
@sameaspastmueed Жыл бұрын
Why did we return nullptr when pointer p points at element which is storing null terminator . Is there a relation between nullptr and null terminator ?
@sameaspastmueed
@sameaspastmueed Жыл бұрын
Please this is confusing
@sameaspastmueed
@sameaspastmueed Жыл бұрын
Also, when the returned pointer to local variable my second cout statement remain the same even after the bar function was called . I beleive when i cout *p I should have gotten ! But instead I got the same value which was A. Why did this happen?
@ProfessorHankStalica
@ProfessorHankStalica Жыл бұрын
the function is returning a memory address of the element containing the target character or it is going to return nullptr. nullptr is designed for use with pointers and null terminator is a special character used with strings. Learn more: kzbin.info/www/bejne/a569aK1qo5WYgdU kzbin.info/www/bejne/a5-Zk4Zjm8Z6aqc
@ProfessorHankStalica
@ProfessorHankStalica Жыл бұрын
That's explained in the video: kzbin.info/www/bejne/iYvSpqVrdtRmfNk
Dynamic Memory Allocation -- C++ Pointers Tutorial [8]
18:25
Professor Hank Stalica
Рет қаралды 29 М.
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
Passing Pointers to Functions -- C++ Pointers Tutorial [7]
19:22
Professor Hank Stalica
Рет қаралды 2,7 М.
C_99 Returning Pointer from Function in C | C Language Tutorials
16:42
Jenny's Lectures CS IT
Рет қаралды 74 М.
C++ Tutorial: Lambda Functions
23:11
Professor Hank Stalica
Рет қаралды 2,9 М.
How To Return An Array From A Function | C Programming Tutorial
13:01
Portfolio Courses
Рет қаралды 69 М.
why do void* pointers even exist?
8:17
Low Level
Рет қаралды 395 М.
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 334 М.
array vs &array Pointers Difference Explained | C Programming Tutorial
17:38
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН