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 М.
A little girl was shy at her first ballet lesson #shorts
00:35
Fabiosa Animated
Рет қаралды 16 МЛН
WORLD'S SHORTEST WOMAN
00:58
Stokes Twins
Рет қаралды 120 МЛН
IQ Level: 10000
00:10
Younes Zarou
Рет қаралды 11 МЛН
What I Did Wrong In My First 6 Months As A Software Engineer
6:10
why do void* pointers even exist?
8:17
Low Level Learning
Рет қаралды 344 М.
String In Char Array VS. Pointer To String Literal | C Programming Tutorial
9:58
the cleanest feature in C that you've probably never heard of
8:13
Low Level Learning
Рет қаралды 132 М.
you will never ask about pointer arithmetic after watching this video
8:01
Low Level Learning
Рет қаралды 237 М.
array vs &array Pointers Difference Explained | C Programming Tutorial
17:38
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 293 М.
you will never ask about pointers again after watching this video
8:03
Low Level Learning
Рет қаралды 2,1 МЛН
Introduction to Pointers | C Programming Tutorial
24:42
Portfolio Courses
Рет қаралды 107 М.
A little girl was shy at her first ballet lesson #shorts
00:35
Fabiosa Animated
Рет қаралды 16 МЛН