function vs. &function Pointers | C Programming Tutorial

  Рет қаралды 8,359

Portfolio Courses

Portfolio Courses

2 жыл бұрын

We can use either function or &function to get the pointer to a function in C, and it actually makes NO difference which we use! In this video we explore and demonstrate that there is no difference between function and &function. Source code: github.com/portfoliocourses/c.... Check out www.portfoliocourses.com to build a portfolio that will impress employers!
Stackoverflow thread referencing C99 documentation that shows the two are equivalent: stackoverflow.com/questions/6...

Пікірлер: 21
@TechnoSan09
@TechnoSan09 Жыл бұрын
Amount of knowledge u have is amazing Superb vid
@PortfolioCourses
@PortfolioCourses Жыл бұрын
I’m glad you liked it and thank you very much! :-)
@zoquevil4792
@zoquevil4792 2 жыл бұрын
Wonderful video !!! using not just c programming but tools like the command line "diff" as well!!! Didn't learn what is a "function pointers" yet but I think with this video I'll enjoying it !! thanks a lot !
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You’re welcome! :-) Here is a video on function pointers if you’d like to learn more about them: kzfaq.info/get/bejne/nMWlirKIu8-9k2Q.html
@sravanakumar9326
@sravanakumar9326 Жыл бұрын
Wow, great explanation as always 🤩
@PortfolioCourses
@PortfolioCourses Жыл бұрын
I’m glad you enjoyed it! :-)
@rogo7330
@rogo7330 6 ай бұрын
It's the same difference as with `char *a = "AAA";` and `char a[] = "AAA";`. First is a pointer to a static text literal and you can't edit it because it can be stored in read-only memory. Second creates an array of chars of same length as of the intializer list (which is string literal with in that case). Function name is the actual function object that degrades to pointer when assigned to one (or passed in as function parameter). Address of the function is just an address, and it is stored in variable that can be edited later. Taking an address of the function name is useless because it degrades to one automatically. Dereferencing it back is useless too, because it looks like function call operator accepts pointer to the function too and in my code it compiles without warnings with -Wall -Wextra -pedantic and standard is chosen. The last one is just my assumption, but I think it is how it works.
@mirabilis
@mirabilis 6 ай бұрын
There is no difference.
@madesimple445
@madesimple445 Жыл бұрын
Bro, who are you?! Thank you for all your work and may God bless you and your family.
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're welcome, God bless you and your family as well! :-)
@justcurious1940
@justcurious1940 Жыл бұрын
Thanks for clarifying this, it's funny I got here because I got confused of pthread_create function too, and how the function requires a pointer to a function but u still can pass the function name only without the AND operator.
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You’re welcome! And that’s funny, I think that was actually an inspiration for this video. :-)
@mirabilis
@mirabilis 6 ай бұрын
Greetings! 🇸🇪 You sound like a Canadian. 😊
@Lklibertad
@Lklibertad 6 ай бұрын
Nice video, could you do something on Message passing interface and maybe mix it with pthreads. it’s a good idea I guess 😂
@-chaaoui7552
@-chaaoui7552 2 жыл бұрын
can we have a video explaining variable function arguments.
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
I have this video: kzfaq.info/get/bejne/ac-IbMSQ0Z-7aY0.html. Is that the topic you're looking for?
@OLIV3R_YT
@OLIV3R_YT Жыл бұрын
Thanks ❤
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You’re very welcome! :-)
@coding-code00
@coding-code00 4 ай бұрын
can you give some exercise in pointer function please
@Amar-pb4bf
@Amar-pb4bf Жыл бұрын
1:10 Did you know that if you really want a function to have no parameters you have to write void. If you leave it empty you could theoretically put in any amount of parameters you want, for example 1 parameter or 5 parameters or 3 billion. This is kinda off topic but just wanted to let you guys know.
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Thanks Amar, that gets covered a bit in this video here on main(void) vs main(): kzfaq.info/get/bejne/ZqqEh9KEubKUYoU.html. When talking about functions casually we would still say a function 'accepts no arguments' if there is no parameters because it's how the function is designed to work in practice.
Dynamically Allocate A 2D Array | C Programming Tutorial
15:58
Portfolio Courses
Рет қаралды 34 М.
Function Pointers | C Programming Tutorial
18:31
Portfolio Courses
Рет қаралды 58 М.
Jumping off balcony pulls her tooth! 🫣🦷
01:00
Justin Flom
Рет қаралды 27 МЛН
World’s Largest Jello Pool
01:00
Mark Rober
Рет қаралды 105 МЛН
String In Char Array VS. Pointer To String Literal | C Programming Tutorial
9:58
you will never ask about pointer arithmetic after watching this video
8:01
Low Level Learning
Рет қаралды 237 М.
Introduction to Pointers | C Programming Tutorial
24:42
Portfolio Courses
Рет қаралды 107 М.
Constant Pointer VS. Pointer To A Constant | C Programming Tutorial
8:40
Portfolio Courses
Рет қаралды 25 М.
NULL Pointer | C Programming Tutorial
18:59
Portfolio Courses
Рет қаралды 10 М.
What are double pointers in C?
14:43
CodeVault
Рет қаралды 42 М.
Memory Leaks And How To Prevent Them | C Programming Tutorial
15:15
Portfolio Courses
Рет қаралды 8 М.
Why are function pointers useful?
6:43
CodeVault
Рет қаралды 29 М.
Jumping off balcony pulls her tooth! 🫣🦷
01:00
Justin Flom
Рет қаралды 27 МЛН