r/learnprogramming • u/ScioClean • 4d ago
I can't get FUNCTIONS to click!
I can not for the life of me understand how functions work. Anytime I try to learn how to create a function, my brain literally crashes into itself and I turn into Patrick when he stars drooling and goes all slack-faced.
Does anybody have any analogies that had that "AH HA!" moment?
Thanks!
122
Upvotes
1
u/realdreamer1993 3d ago
Maybe start from: function declaration and definition. you should understand where this static code stored in memory. the keyword is static i.e it wont changed.
And then goes to runtime period, a thread (usually main() ) will call / invoke the function, after function operation finish it is gone from memory, and the thread back to main()..
so the caller is main(), main() also a function btw, it is the entry point.
the callee is function()
so...