I studied C native in University on Solaris and this explanation of pointers is far and away better. Better on all fronts. Well done Sir.
@skilz80985 жыл бұрын
This is just the basics, here he is only addressing it... wait until you work with dynamic memory and the heap... I've learned C long ago but I'm more familiar with C++. The basic way to create a block of memory in C++ is with new and new[] and to free them is with delete and delete [] respectively. Today, this is considered bad practice unless you truly know what you are doing and you have a very specific reason for using "raw pointers" as the conventional way is to use std::shared_ptr and std::unique_ptr... In C this is done with malloc() and free() and some other memory-based functions.
@Seaprimate5 жыл бұрын
I feel that despite not having any fancy visuals or elaborate analogies, I feel I intuitively understood more in these 10mins with your video than I did through multiple other longer videos combined. I don't know how you did it but thank you!
@Hunter725R4 жыл бұрын
Me: Visual Studio for C with autocompletion for smallbrain Him, a divine being: nano on a Rasperry Pi Zero for C.
@SwedishDude084 жыл бұрын
@Christian Weissmuller Vim is evil, use emacs instead and enjoy your sprained pinky!
@dgaa19914 жыл бұрын
@@SwedishDude08 Well Evil Emacs is kinda nice :D
@volkerking59324 жыл бұрын
@Christian Weissmuller vim is for noobs use xemacs!
@Andrew-wo8ry4 жыл бұрын
Notepad++ gang.
@ihitonmilfs3 жыл бұрын
you guys still use nano? real men just echo "#include int main(){printf("Hello World");}" >> program.c
@liamhulsey91582 жыл бұрын
Currently in a college course learning C and this is the only explanation I've heard in class or on the internet that makes pointers make sense. Can't thank you enough.
@GaryExplains2 жыл бұрын
My pleasure. I hope your courses go well 👍
@john_avernia2 жыл бұрын
I just started learning programming (several weeks now) and your video really helps me a lot in understanding pointers. Which is, from what I heard, is one of the hardest subject in C programming.
@SwedishDude084 жыл бұрын
To people getting this error message from gcc: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘int *’ Change %x to %p and it will work.
@davidmella11744 жыл бұрын
yes, some things have changed with the new C standards in the compiler.
@boazvoort68693 жыл бұрын
"%d" worked for me
@skylo7065 жыл бұрын
Oh I wanted to make a tutorial on pointers myself called "How to SegFault in C"
@qwerasdfhjkio4 жыл бұрын
Lol
@fifaham5 жыл бұрын
I have been browsing for tutorials and found many on KZbin for things I already know, I found yours to be one of the best and I will keep your link here with me. Job well done.
@LoyalSlime6 жыл бұрын
sir please do more C tutorials
@GaryExplains6 жыл бұрын
If there is enough interest then I will.
@thomasb13376 жыл бұрын
I'd love it. I'd even pay for it on something like udemy =.
@josh4296 жыл бұрын
+1
@stephenjames57456 жыл бұрын
That would be amazing!
@nikhil.n6 жыл бұрын
sir we are interested in programming tutorials do make more of them.
@Ejeby3 жыл бұрын
4:30 & tells you the address, * tells you the dereferenced value 6:50 in c an array name is equivalent to its pointer 7:30 increment the pointer
@MrGman5905 жыл бұрын
Now I understand how pointers work, after 4 years of trying. Thanks for explaining, Gary!
@ShadowPianoProductions3 жыл бұрын
Dude, you're a godsend, I could not understand pointers for the life of me before watching this video
@JJSogaard3 жыл бұрын
I'm just in the beginning of getting into C after learning Python. There really is something beautiful about how basic and (relatively) low-level it is.
@DrSpooglemon3 жыл бұрын
Scared the b'jesus out of me moving from the well ordered metropolis of Python to the wild west of C.
@abrahamnzau2542 жыл бұрын
By far the best explanation of pointers I have come across
@ST959536 жыл бұрын
my teacher couldn't explain this properly. Thanks!
@easymatrixyt3264 жыл бұрын
Lol
@cy4n_knight_q84 жыл бұрын
Your teacher tried to explain this? Mine didnt even bother to explain lol
@froggyy3 жыл бұрын
Change your college
@CodyHoskin3 жыл бұрын
Haha same
@johndripper3 жыл бұрын
Read books😔🙏🙄its not even a hard concept to grasp
@mukukakondowe59392 жыл бұрын
Thank you for demystifying pointers for me. They have been a real pain in my neck.
@D3ND6 жыл бұрын
Great video! pointers are definitely one of the more tricky parts of C that I have faced, especially when going for data structures (linked lists, dynamic arrays... ) with allocating and freeing and so on...
@brokenicry5 жыл бұрын
I went through so many tutorials just to understand this...Only this single fast-paced video helped me understand... Thank you. Please tell me there are more videos like this
@陈瀚龙5 жыл бұрын
Old guy here. I've been self-teaching Java and soon to start Android, but not sure how to approach learning Android. I decided to take a break and learn some C and explore Linux more in-depth which led me to this video. It was nice to see you using NANO and excited to hear about the Java/Android course. I'll have a look. Great job with this vid, short as it was, good introduction to pointers.
@eatscaper6 жыл бұрын
Your tutorial in C was superb ! Make more tutorials and gain the attraction of new developers and of course you are great !
@felaflame5 жыл бұрын
Excellent explanation. Simple, going straight to the point.
@akhilsreedhara9684 жыл бұрын
you have taught pointer better in 10 min than my professor has in 3 hours
@aliftaufik19346 жыл бұрын
The question is why should we prefer using pointer rather than using, for instance, the index number of array to loop it??
@danielgysi57296 жыл бұрын
This is what I hoped this video would explain. Unfortunately I'm left feeling more confused than when I began
@SamChaneyProductions6 жыл бұрын
Pointers allow you to change the value of multiple variables from inside a function, and they even allow you to pass functions as arguments into other functions, both of which are impossible without them.
@RadicalEagle5 жыл бұрын
@@SamChaneyProductions thank you! As someone who is not familiar with C I couldn't quite understand why this was important.
@reiniertl5 жыл бұрын
There is a very interesting advantage but I really don't recommend it unless you really need the most performance. When you use array indexing in a loop the compiler (in theory) generates code to bring into the CPU registers the base address of the array and the value of the index, then it must compute the address you want to get access to. So you need two read access and a sum (all this is in machine code so it is very architecture dependent). When you use a pointer to access the elements of the array and you are traversing the array in a fixed pattern you can take advantage of pointer arithmetic, since you are incrementing the address by a fixed number the compiler generates code to bring the address value to the CPU register and the increment will be put into the ADD instruction code, so you save at least one instruction per access (no need to fetch the index value from memory). For example, the code bellow shows the differences: #include int array[10]={100, 200, 300, 400, 500, 600, 700, 800, 900, 1000}; int main(){ //This is a bit slower but more clear int val; for (int i = 0; i
@jvarennes5 жыл бұрын
Better to use pointer when, for example, you don't know what the array size will be at the beginning. Let's take a text file which has to be parsed and values stored. First, you do a malloc which gives you a pointer and begin to read the text file. Then, if you haven't allocate enough memory, you can do a realloc and continue to read and parse the file.
@JesusMartinez-zu3xl3 жыл бұрын
You literally taught me in 12 minutes! compared to what my professor taught us... Thank you!! also understood you much more better.
@arjunkharbanda6 жыл бұрын
One of the best video on pointers. Please make more such programming videos like Data Structures etc
@cookymonstr7918 Жыл бұрын
It dawned on me as you were typing (3:11) *aptr = &x because in a variable "aptr" you literally store the (hex)value of the address of an "x", which is nothing else than &x. No more, no less. The only thing that confuses me a bit is that doing "pointer arithmetics" decimal number is added to hexadecimal...
@GaryExplains Жыл бұрын
Decimal and hexadecimal are just ways we represent numbers for humans. The numbers are the same. Adding 15 to something and adding 0xF are the same thing.
@pcache4 жыл бұрын
I didn't learn anything new about pointers, but boy oh boy I had no clue some shells supported the exclamation point notation for repeating previous commands, that makes me excited.
@woomlrweiriwueiru5 жыл бұрын
Best pointers explanation I've seen!
@JM-yj4yy4 жыл бұрын
has pointer exam in 2 days, bless you KZbin algorithm, sweet child
@dwagner65 жыл бұрын
Been a while since you shared this, but a better explanation than my professor at uni explaining c++ pointers. Cheers.
@MarcelN19803 жыл бұрын
Thank you Sir, subscribed in 2021, all the very very best from Romania :)
@NinjaRunningWild2 жыл бұрын
That sign behind you terrifies me, fully understanding what that will do. Happy debugging!
@GaryExplains2 жыл бұрын
Why should that terrify you?
@GaryExplains2 жыл бұрын
Here is a little C program using the code on the signpost! #include int main() { int **ptr; int *ptr2; int x=42; ptr = &ptr2; *ptr = &x; printf("x is %d ", **ptr); return 0; }
@OMNI_INFINITY2 жыл бұрын
Is it possible to make the val of a non-pointer var a mem address and then use the * operator on that normal var to get the val in the mem address that is its val? There must be some way to do that, unless it was architected to not allow that (doubtful)
@GaryExplains2 жыл бұрын
Why a non-pointer var? I don't see the need or benefit. As a side note, with casting you can convert almost anything. For example: #include void main() { int x = 42; long y = (long) &x; int *p = (int *) y; printf("%d ", *p); } Output: 42
@OMNI_INFINITY7 ай бұрын
@@GaryExplains Apologies that I didn't see that reply until today. Thanks for including that nice example code!👍🏻
@kc28384 жыл бұрын
Sir, please do more videos on more C concepts.
@thsdsyt5 жыл бұрын
The star (*) is called the indirect operator because it access indirectly the value of a variable through the pointer.
@emilyboyle7240 Жыл бұрын
this is the best explanation ive come across so thank u for this. i am curious as to what the point of pointers are. to fill the array u also could have just referenced each index as well
@GaryExplains Жыл бұрын
If you had a large Image that you want to process in a function, should you pass the whole 5MB to the function or just a pointer? They are also useful for many types of data structures, see my video on linked lists.
@nagesh0076 жыл бұрын
Thanks a lot , can you please teach " C structures and unions" ?
@neelparekh17593 жыл бұрын
It's easy 🙄🙄, I hope you have learned till now 🤣🤣
@Dish.Washer3 жыл бұрын
@7:49 Isn't saying somenumber[5] going out of the array?
@xiajack15073 жыл бұрын
the for loop terminayion condition is ptr
@fazp2 жыл бұрын
this video made sense for me and it gave me an idea what a pointer really is to my small brain 😂
@jourkevin52542 жыл бұрын
missed that part at school because of the covid , had trouble with the array part. Thanks for the video. Aannd subscribed
@Kakashiownsyou2 жыл бұрын
Big ups for Nano. Big ups for good display colors. Salutations, friend.
@StannyObelisk3 жыл бұрын
Gary mate you’re a legend
@nayanarora49663 жыл бұрын
Best explaination I have ever seen
@eren82275 жыл бұрын
shouldn't printing the address of what pointer holds be with %p and proper type casting?
@JP-nj2sl5 жыл бұрын
Very clear explanation of pointers
@KoKoKen2 жыл бұрын
commenting four years late but thanks dude this was massively helpful
@GaryExplains2 жыл бұрын
You're welcome!
@ujvalmadhu54823 жыл бұрын
Can someone explain the purpose of a pointer, because you can just directly increment the index of the array (somenumbers) to update its values right? Instead of using a pointer? Why not call the variable directly??
@FritsvanDoorn5 жыл бұрын
Your main function should return a value. Other declare it void. Good explanation! Very clear.
@GaryExplains5 жыл бұрын
LOL, not the grammar police, but the code review police. 😂
@michaelshort23883 жыл бұрын
Thank you for the informative video. Is there any benefit to using a pointer to traverse an array vs the traditional way?
@suma4m6 жыл бұрын
3:00 Why does this: {int *aptr = &x;} and this: {int *aptr; aptr = &x;} give the same result? Why the asterisk can be placed both before variable name or after the type name?
@GaryExplains6 жыл бұрын
{int *aptr = &x;} is a short form of {int *aptr; aptr = &x;} In the first the pointer is declared and initialized in one swift move. In the other the pointer is declared and then initialized in a second statement.
@filker05 жыл бұрын
As for why "int* ptr;" is the same as "int *ptr;", the space is not required by the language syntax. The type of the variable "ptr" is "int *", read as "pointer to integer".
@TheTestr5 жыл бұрын
The confusing part is that you use * to tell C that a variable is a pointer. But when you want to save something in this variable you use & to get an adress and * to get a value. I do not understand, why it is not the other way around..
@johng7rwf4195 жыл бұрын
That took me back more than 30 years..
@1MarkKeller6 жыл бұрын
*GARY!!!* *Good Morning Professor!* Great video as always!
@GaryExplains6 жыл бұрын
MARK!!!
@willd98072 жыл бұрын
How did you get it to compile without return 0;
@Goodbirb2 жыл бұрын
I've always used vs code, but now um curious on how do you code in the terminal like that
@eliasdetrois4 жыл бұрын
Great tutorial. Thanks
@arunsc374 жыл бұрын
Thank you this is 30x better than my prof
@Abdulrahman-uk9ny6 жыл бұрын
Thanks a lot for the very good explanation. I am about to enter the final exam of C in college... I didn't understand the language well, but I may pass the exam... I think I need to study the C language again in detail.. please make a whole tutorial for C language.
@michaeldausmann67365 жыл бұрын
Great video Gary.
@DavidBarnwell876tkdja2 жыл бұрын
I'm getting some strange output. I'm getting 5 outputs. The first gives the value 2, then, values of the other array elements (all 0) then the fifth value is the memory location of the last element. Then, it repeats with 2, hen, 4, then zeros, until it prints the memory address of the last location. This happens 5 times until the array has been completely filled. It's weird ..I can't see what could lead to that behaviour, Never mind..I had the second for loop enclosed inside the first..that was the problem. It's all good now.
@CaptainWumbo3 жыл бұрын
it would be nice if you explained why you would want to use a pointer over access by index. Is it more efficient in some way? It looked to require a bit more knowledge to read. I never did anything with C before, so the only value I can intuit is that passing a pointer to a function can save copying the value in cases a copy doesn't help. It's not clear from the video why you would prefer to deref a pointer over using a variable directly.
@GaryExplains3 жыл бұрын
Well, why you would use pointers is different to how. This video is how. Check out my video on linked lists for an example of why.
@davidpotesta5 жыл бұрын
I get a compilation error if I try printf("aptr is %x ",aptr); The compiler (correctly) tells me that aptr is a *int. To print the HEX address of what aptr points to I need to use the format specifier for a pointer which is %p and use this: printf("aptr is %p ",aptr); and it works. I guess my question is, why did your program compile with a format specifier that mine does not?
@GaryExplains5 жыл бұрын
Yeah, my version is wrong. It depends on the compiler and the platform, I guess.
@davidpotesta5 жыл бұрын
@@GaryExplains Thanks for the quick reply and for verifying that I wasn't crazy. Thanks for all of your great videos!
@canaDavid14 жыл бұрын
One thing that frustrates me in c/c++ is how a pointer is made. Ie Char *ptr = &x; But as i have understood it, * dereferences the pointer. (And & tells us the adress of it). This code seems to suggest that in wherever ptr points, write address of x. But what it means is to write &x at ptr, no dereferencing. Therefore, I always write 'char* ptr' with the * before the space, to clarify this. Is this an oversight or am I just being silly? (My format is a problem if you are doing multiple variables: 'char* a,* b' should be 'char* a,b' in my opinion)
@GaryExplains4 жыл бұрын
Yes, lots of people have the very same issue and they write the * to the left as you. For me it has never been as issue, because it only occurs when doing a variable declarations, so you just learn it for what it is.
@canaDavid14 жыл бұрын
@@GaryExplains Well that's a quick reply! Nice to know I am not the only one.
@galvanizeddreamer20513 жыл бұрын
Finally, someone explaining what something is.
@Jool48322 жыл бұрын
Unrelated question: what's the name of the music you're playing for this video?
@volkerking59324 жыл бұрын
Hello Gary one question about the first => for(;ptr < &somenumbers[5]; ptr++) I know that the pointer is at the start of this "for" on the correct point but where is this? you write => for(; - what is normal between the '(' and the ';' I make a attempt => for(ptr = &somenumbers; ptr < &somenumbers[5]; ptr++) {.... but my start condition follow by an error what is the correct start position of the pointer?
@GaryExplains4 жыл бұрын
The first section is for initialisation. Your test was almost right, but should be "for(ptr=somenumbers;..." You don't need the & as an array is a pointer to itself. You could also do "for(ptr=&somenumbers[0];..."
@volkerking59324 жыл бұрын
@@GaryExplains what I understand now = after making a error 'int somenumbers[5]; int *ptr = &somenumbers; - A array[5] is a hardware address itself! after initial a array[5] it is not need to say this is a addr in the RAM I only can say int *ptr = somenumbers; and this will accept it as a arrays first addr inside the RAM or where else. My pointers are xh,xl yh,yl and zh,zl over R0 :-) I only know how to program in assembler and this 'C' is only for lazybones - reason you never need to manage the vectors itself that is doing the compiler and not your brain. hahaha Super I learning again the 'C'! Thank you Gary! Best Regards Volker from vienna
@GaryExplains4 жыл бұрын
@@volkerking5932 For arrays only, the array name without square brackets is always the address of element 0. So 'somenumbers' is the same as '&somenumbers[0]'
@volkerking59324 жыл бұрын
@@GaryExplains I see - wow that is a little bit complicated for me in the start sequence. I understand it I come from the assembler language but my story is harsh. I've be in the hospital in 2017 and my pancreas is died inside my body. The hospital send me for 61days to deep sleep comma and in sum it was 128days hospitalized. But that was hard and I loose all my knowledges/skills inside my brain so I must learn all again. I can't remember what I've done before my visit in the hospital? I learn now from 2017 September to calculate - yes I must learn mathematics and reading/writing that was also a bit hard for me to understand - ironical the assembler programming I don't forget but that I have had a wife and children that I can't remember. After this hospital they told me I've a family - I can't remember it. The people of my family was foreign for me and I can't live with the woman again so I leave her. She was a foreign person for me I can't remember nothing about us. No pictures and no feelings that was missed after this hospitalization. In case of the hard medication they gave me inside the intensive care I lost all data in brain from 2007 - 2017. I remember only things that far away in the time line. For example I remember back in the 80s very good and my learning time at Grundig (TV & Videorecorder Company). I must say thank you very much to you and I like this Video. Best Regards Volker from vienna thumbs up Nr. 4964
@c0ldw1nd274 жыл бұрын
I already knew everything, but I still watched the whole video.
@DaSnipy5 жыл бұрын
Thank you so much Sir .. Such crystal clear explanation with demonstration.
@dutoitvandyk25316 жыл бұрын
well done, really well done. Can you please continue to teach C in such a understandable way.
@GaryExplains6 жыл бұрын
I am glad you liked it. I will certainly do more C tutorials from time to time, but my only concern is that they don't seem that popular.
@dutoitvandyk25316 жыл бұрын
i can see that from the views, I feel like there is so little interest in C because it is quite a difficult language to learn, especially as a first language. Its my first language I am learning but only because it's a module i have too finish for my degree . I would personally like to learn python first, love the language and the simplicity. I have learned a lot in this video and used it to do one of my tutorials. I've spent about 3 days now trying to figure out how to assign new values to an array and keep the memory addresses. Then it needs to give the new values for the array and the addressees. Just can't seem to get it right..... The fact that the C videos are so unpopular might actually have to do with the fact that no-one is interested in learning it as a first language and because of the immense lack of useful videos on it, which is kind of a vicious cycle.
@raphtlw5 жыл бұрын
Hey Gary, can you do a video on the difference between C and C++ and C#? Thanks for these awesome videos!
@GaryExplains5 жыл бұрын
Hmmm, that could be an interesting video... thanks for the idea.
@raphtlw5 жыл бұрын
@@GaryExplains ❤️❤️❤️❤️ I honestly can't believe you replied
@yoelin92533 жыл бұрын
This was so incredibly helpful! Thank you!
@GaryExplains3 жыл бұрын
Glad it was helpful!
@nousernamealexander4 жыл бұрын
I still can't explain pointers by myself. I still can't understand where I need to put a pointer when I am doing an exercice. Do you have some exercices to help me ?
@yapayzeka5 жыл бұрын
behind you what is the type of pointer pointing :D
@patrickdeniso6 жыл бұрын
Thank you! You explained pointers really well
@wedsonlopes25596 жыл бұрын
please, do more classes like that!I am now subscribed.
@KangJangkrik4 жыл бұрын
Subtitle at the beginning: hello my name's Gary simps
@thejavaman536 жыл бұрын
But i still cant figure out why to use them when we can definitely ignore them and still create a similar program.
@GaryExplains6 жыл бұрын
The power comes when you do more complicated things.
@jadenlorenc25775 жыл бұрын
Dang this guy does a really good job
@supergoofy1236 жыл бұрын
Thank you. We need more videos like this.
@GaryExplains6 жыл бұрын
I will certainly do more programming videos including C and Python. However they aren't the most popular type of video, so I will only be able to do them from time to time.
@ProductionCowbell2 жыл бұрын
Very informative video 👌
@throwitatthewall62892 жыл бұрын
Understanding pointers was pretty easy from this. What I fail to see is why it is better than just referencing the variable.
@GaryExplains2 жыл бұрын
If you had a 4MB image and you wanted to apply a filter, would you pass the 4MB variable to the filter function (which means allocating another 4MB and copying the image) and then return another 4MB (with allocation and copy). Or just pass the few bytes needed for the pointer?
@grasshopperweb5 жыл бұрын
What about constant pointers? My text goes through them far too fast and I don't fully understand lines like int const * const pointer = &adr;
@RushilKasetty5 жыл бұрын
When reading const, read from right to left instead of left to right. So, the pointer variable is a "constant pointer to a constant int". This means that after creating the pointer, you won't be able to change which object it points at, and you won't be able to modify the object it's currently pointing at. The first const (as in int const) means that the thing the pointer is pointing at can't be modified. The second const (as in const pointer) means you cannot change what object the pointer points to.
@grasshopperweb5 жыл бұрын
@@RushilKasetty thank you very much! Clear explanation
@nonamejoname67285 жыл бұрын
I copied your first code into my IDE, but it does not work. It returns this error: error: format specifies type 'unsigned int' but the argument has type 'int *' [-Werror,-Wformat] What am I doing wrong?
@GaryExplains5 жыл бұрын
Obviously I can't tell just from the error message, I need to see the line of code that is producing the error, so we can check it.
@nonamejoname67285 жыл бұрын
@@GaryExplains printf("aptr is %x ", aptr); The error is occurring in that print statement. Actually, I just used another IDE, and it worked. CS50's IDE wasn't able to run the code; Code::Blocks was able to.
@GaryExplains5 жыл бұрын
Technically the compiler is right in that a pointer isn't an unsigned integer. A bad habit of some C programmer (myself included) is to treat a pointer as an integer (since it is an address). Here are two possible alternative that the CS50 IDE might like: printf("aptr is %x ", (unsigned int) aptr); printf("aptr is %p ", (void *) aptr);
@nonamejoname67285 жыл бұрын
@@GaryExplains Both worked. Thank you for taking the time to explain all of this to me. I'm a newcomer to programming and slowly learning the important things. You've helped me get a little bit closer to where I want to be. Thanks again!
@vishma91663 жыл бұрын
Thank you very much Gary. Very helpful.
@radddish6 жыл бұрын
thanks gary that helped a lot !
@ahmedomar2223 жыл бұрын
No man, please. No asterisks on the name
@dev-patel5 жыл бұрын
I cant initialize in the middle of code I have to initialize any variable at in start? how can you do ?
@JohnSmithZen2 жыл бұрын
Why might someone use pointers on non-arrays?
@GaryExplains2 жыл бұрын
If you loaded a photo into memory and you wanted to pass it to a blur function, would you pass the whole multiple megabytes data or just a pointer to it?
@DanielAlmeida4993 жыл бұрын
Great video! Thank you
@lukenukem80284 жыл бұрын
Pretty cool. But, what is that primitive program you're using, and primitive OS? Is it like a DOS legacy inspired thing for certain people? I need to see my project structure, seriously, all files, etc.
@GaryExplains4 жыл бұрын
I tell you what I am using at 1:42
@lukenukem80284 жыл бұрын
Oh, I def heard the pie and nano. Is the pie a computer, or OS on a computer, is it a console, terminal? Others use Sublime for C so I'm guessing Nano is something required for use on Raspberry Pie?
@lukenukem80284 жыл бұрын
I heard it, but it doesn't tell me anything. LoL
@GaryExplains4 жыл бұрын
@@lukenukem8028 It seems you are missing some fundamentals here. I have videos covering just about every question you asked here. The comments section isn't the place for me to fill in the gaps for you.
@lukenukem80284 жыл бұрын
This is the first video of yours I've seen. I'm only asking what R.Pie and Nano are.
@JadedBeast6 жыл бұрын
Cool logo you have there , and thanks for making this video
@ashwani_kumar_rai6 жыл бұрын
What is !n and !g you used on terminal
@alliejr6 жыл бұрын
In the shell he is using, !n will rerun the last command that was run that begins with the letter "n". The "!" is the "bang". You could also do something like "!25" to rerun the 25th command in the history of commands previously run. To get the history, use the "history" command.l
@D3ND6 жыл бұрын
alliejr does that work in any Linux terminal?
@apsancentury60136 жыл бұрын
alliejr That’s awesome.
@alliejr6 жыл бұрын
Haha you're testing my memory too much to recall which functions are featured in which shells, but the simple answer is, "NO". In Linux and all other Unix variants (including Mac OS), you have a choice of different shells. The Bourne shell (sh) is the grand daddy of all shells. In Mac OS, the default shell is the Bourne Again SHell (bash) which is similar and mostly compatible with the Bourne shell, but has some improvements. If you want to use history and bang, use sh or bash. There are also other shells (e.g, csh, zsh) and I don't recall which shells support which features.
@GaryExplains6 жыл бұрын
zsh and tcsh also support history and !
@josh4296 жыл бұрын
Gary could you explain make and makefiles please?
@GaryExplains6 жыл бұрын
That is a good idea... I will add it to my TODO list.
@josh4296 жыл бұрын
thanks
@santosshresth44195 жыл бұрын
love your contents here can u make a video explaining the digital ciruit realization of how pointer works?
@barakyehudagortler62656 жыл бұрын
tnx you explain in an interesting and clear way
@cweasegaming26926 жыл бұрын
It will not let me use %x ?? It throws this : warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘int *’ . I tried it with just %p and that worked, but is obviously longer. Any idea? Edit: It works, but still throws that error. I'm curious as to why it didn't do that for you?
@GaryExplains6 жыл бұрын
What platform and compiler are you using? What if you try: printf("aptr is %x ", (unsigned int) aptr); Does that work?
@richardturnnidge5 жыл бұрын
Really love your videos. I have been coding (amateurishly) since 1981 and although I fully understand what pointers are in C, I am still at a loss as to why I would use them over regular variables. Your video clearly shows how a pointer can work just like a variable, but what is the advantage of a pointer?? If today's compilers are very good at their job, they would create the same executable which ever way it was coded, surely? Does using pointers help instruct the compiler how to do their job? make the compiled code faster?? leaner?? is that an issue today? I am sure that there must be some examples of where pointers are essential that normal variables could not work, but maybe that would be too advanced and therefore not covered here? Please, give us an example or two where pointers really come in their own and we can really take advantage of them!! Thanks!
@GaryExplains5 жыл бұрын
Here are two examples of where pointers are useful. 1) Data structures like linked lists. You can manipulate the data structure, and access it, using pointers. Very fast and every efficient. I have a video here: kzbin.info/www/bejne/d5ylZ2R-Zpp7gNk 2) Passing information from one function to another. If you have a block of data you don't want to pass the data by value and copy all the data onto the stack or heap, you can just pass a pointer to it. For example if you are manipulating a 6MB jpeg file in memory. You wouldn't pass around the image itself, but rather a pointer to it.
@drcl74295 жыл бұрын
The main reason is higher speed and lower memory - mostly when using functions. If you pass a large array to a function, the program must make an entire copy of the array. This requires a lot of CPU time and memory especially if you use that function regularly. If you use pointers, you only need to pass the memory address of the original array. No copying required so no excess cpu or memory usage. The trade off is you have to think a bit more and be careful not to reference memory you aren't supposed to.
@ammaribrahim57566 жыл бұрын
what assign addresses to memory locations such as bea54240? is it the bios?
@GaryExplains6 жыл бұрын
It depends. If the pointer is a local variable then the compiler will get the address from either the heap or the stack. If malloc() is being used then the address comes from the OS.
@ammaribrahim57566 жыл бұрын
@@GaryExplains Thank you for your effort and your awesome videos... Mr.Gary......