Pointers - CS50 Shorts
HTML-код
- Опубликовано: 24 окт 2017
- ***
This is CS50, Harvard University's introduction to the intellectual enterprises of computer science and the art of programming.
***
HOW TO SUBSCRIBE
ruclips.net/user/subscription_c...
HOW TO TAKE CS50
edX: cs50.edx.org/
Harvard Extension School: cs50.harvard.edu/extension
Harvard Summer School: cs50.harvard.edu/summer
OpenCourseWare: cs50.harvard.edu/x
HOW TO JOIN CS50 COMMUNITIES
Discord: / discord
Ed: cs50.harvard.edu/x/ed
Facebook Group: / cs50
Faceboook Page: / cs50
GitHub: github.com/cs50
Gitter: gitter.im/cs50/x
Instagram: / cs50
LinkedIn Group: / 7437240
LinkedIn Page: / cs50
Reddit: / cs50
Quora: www.quora.com/topic/CS50
Slack: cs50.edx.org/slack
Snapchat: / cs50
Twitter: / cs50
RUclips: / cs50
HOW TO FOLLOW DAVID J. MALAN
Facebook: / dmalan
GitHub: github.com/dmalan
Instagram: / davidjmalan
LinkedIn: / malan
Quora: www.quora.com/profile/David-J...
Twitter: / davidjmalan
***
CS50 SHOP
cs50.harvardshop.com/
***
LICENSE
CC BY-NC-SA 4.0
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License
creativecommons.org/licenses/...
David J. Malan
cs.harvard.edu/malan
malan@harvard.edu
Man I feel sorry for the people who might be skipping over these shorts. The main lectures are great but Doug just clears up so much for me here.
Agree. I am one of those people who skipped shorts and now I have to get back and watch them
@@bpospanov made the same mistake, catching up right now, and so many things have become much clearer for me ..
Bro, like literally no one has explained pointers in depth or as well like you have in this course. WHY are CS teachers not great at explaining this. It's like they expect us to hear their metaphors and completely understand how to code a pointer. I appreciate you going through all the logistical things that students get confused about, like why is there a asterisk on that value but not the other we, and why to we use ampersand sometimes. I think the teachers just assume we are either smart or dumb, but in reality we can only start learning once something makes sense to us logically, rationally, and most importantly if we know WHY we are doing this. I really wish my previous teachers would have just shown me this video.
Also pass by reference and values makes so much more sense to me now. Arrays are basically pointers but with no *, and the goal of using a * is to get a normal variable (char or int, whatever) to act like an array. Arrays are pass by reference and variables normally are not. The reason we might want this is because variables DON'T SAVE VALUES when we put them into functions (aka if variable x is put into a function where x = "hi", the end result will not save x as "hi" because this is pass by value). But array do get saved in functions. If we want to save values into variables just like how arrays automatically do (from inside a function), we use pointers.
IDK why I wrote this, I think just to vent and help myself understand this. I've been struggling on pointers for soooo long, thank you really, I appreciate it a ton.
Pro tip: Instead of declaring pointers as type* name, you can just declare them as type *name (there's no difference). This'll prevent any confusion that you might get from declaring multiple variables at once on the same line as stated at 23:49.
That's the question I was wondering throughout all time! Thanx for your tip, Neo!
(int* a = pointer) (*a = value stored on 'a' address) i think writing like this it's better for understanding because are different things
That's also what they doing in the CS50 lectures (at least in the 2019 version)
@@AlexandreMiguelf i agree, "unpack" the actual value in the memory while a is a data type, aka pointer, that stores reference(address), writing in this style is more intuitive
personally i like: type * name
This is amazing. Finally some C videos that are clear and understandable. Thanks! These are going to be lifesavers this semester.
Two weeks worth of reading and lectures compressed into a few minutes that make 50 times more sense
For me, this is easily the best video on pointers on youtube. I wish I had this during my CS undergrad!
Im a first year student of computer science at a local community college, just wanted to say thank you to the cs50 team, their tutorials and lectures are so much better and clearer than my school's. Got the aha moment immediately after this video, Lloyd and David are great at breaking down confusing topics and making them very comprehensible. Appreciate the help, wish you guys had all the CS classes at Harvard, but I guess thats asking too much.
brother has hopefully graduated
@@SaadKhan-kk4ni I hope so
@@rubiano3i hope so as well
The notebook analogy was incredible! I’m not used to working with pointers but that part alone really cleared everything up. Keep up the awesome work!
Doug Lloyd you are the best! Thank you so. so. so. much. Can finally wrap my head around pointers!
The way how he explained pointers was really comprehensible. Thanks Dougg, best video so far :)
Thank you very much, David Malan and everyone on cs50 staff!! You´re amazing . All that for free is just unbelievable!
Beautifully explained Doug. Found your description and explanation so easy to follow.
Of course, it's going to take me a while to understand ti well enough to implement them into my work but that's on me!
It's been some years ago, but with headphones the "puff" sound from some midlow voice frequency could be diminished by putting a bit down around 500hz into the sound mix.
This video helped a lot. Doug you did great here.
Don't give up. Yesterday it seemed impossible to understand, today it's already much clearer.
27:13 the conclusion is probably the most useful part of the video
Doug my man, i want to hug you mate, thanks for the incredible explinations, so much make sense now... Keep the great work
Amazing video series! Absolutely clear and well formulated examples. Thank you so much for your time and effort you really do make the internet (and the world) a better place.
On a side note, I wish you would go more into the syntax like using pointers to structs and accessing the instance variables using -> etc.
I was so confused right up until the very end in the final diagram where you showed the k and *pk, I finally understand how to use a pointer, thank you so much.
The best explanation of pointers I've seen or read so far (as a beginner).
Awesome video! Straight to the point, easy to follow, and full of useful info. Thanks!
Dereferencing was the part , I used to get stuck up . You just nailed it mate .Cheers
OMG . wish I had a C language teacher like you 20 years ago !! thanks a million
Love what youre doing Doug.
Huge thanks!
Simply amazing how good this video is.
Great video. I finally understand pointers. I also recommend others' in this comment section to search for "call by reference vs call by value" to really cement the concepts. Thank you!
My man Doug dropping shorts like they're unskippable DLCs lmao
Thanks for this video; before this I was using pointers sometimes to get something working but the next time i use it, i know what i'm doing :)
Watching these shorts after the main lecture is very helpful
Love CS50! Very good explanations. Guys, you are the best))
finally i understood pointers so well . THANKS Lloyd
Thanks a lot Doug, you've been really helpful.
I really like when he says "it's a lot easier to think about it like that as a human being" XD
thanks doug, once again a great summary to a abstract topic
Thanks Mr. Lloyd, you are a good teacher!
I think you have phenomenal teaching skills. Bravo!
Holy cow I think I'm starting to understand pointers in C!!! Thank you CS50! :D
Really good job, Doug! Thank you
The syntax distinction between the two uses of * in the context of pointers is very useful to me: int* c (declaration of pointer) and *c (dereferencing that pointer). The lecture isn't (always) always doing this, e.g. declaration of pointer p in lecture 4: int *p.
Is my laptop dying or are there sometimes horizontal lines appearing onscreen?
same.. It's video fault
Pointers, a subject so heavy it makes youtube images start to flicker.
it's the green screen
same
there's a glitch in the matrix
The last 5 mins of this video helped me a lot. I guess it's mainly because I am not a native English speaker. Most part of the speech just drifted in front of eyes.
The moment that he explains that string is actually the collection of characters, but not a data type.. Oh man! I feel enlightened!!! :D
amazing lecture, thanks a lot
amazing work keep on great CS50
Thank you! This is a life saver
What can I say? Absolutely clear and smooth explanation of pointers
Amazing explanation, thanks!
Thank you, Doug Lloyd!
I totally agree that what makes pointers so complex is its syntax. sometmes * is just literally a symbol represnetating it is a pointer when you declare it, and then next time, it's a dereference operator where it takes you to a value pointed by a pointer address
Amazing video, thank you so much!😍
Great material, thank you.
Awesome video but for a moment I thought my screen was broken with all the green lines 😂
This video has some really useful pointers.
Finally, I'm here to understand more what pointer is.
thank you so much for this
I understand a pointer as a variable that holds the address of another variable. to extract the address of a variable, we use the & operator, which returns a pointer. derefencing is a way of getting the value located in memory. to achieve dereferencing we need the address of a varible.
thank you Doug!
Good explanation! The only issue is "all pointers are just addresses". Actually pointers are variables which contain the address of another variable.
"When we learn the difficult, everything else become easy". I mean, I think if we become experts in Pointers, so the entire C will become easy to learn and I guess that, all programming languages becomes easy too, like a domino effect. Awesome lesson Professor Doug Lloyd, thank you.
@17:47 it was actually the Arrays Short where set_int and set_array were used; not Variables And Scope
I wish this video came out when i was in undergrad haha
Thanks a lot!
Pointers are especially useful when you have an array of objects and you don't know which object stores this specific value and you wanna make a change to the object so you use pointers so you can actually change it.
that helped a lot , thx :)
Hey Doug, great video! Although, i had a doubt. Do the light green boxes (pointers) take memory and if we free(some pointer), do the light green boxes always remain in memory or what ?
Between the lecture and the short I’m surprised there hasn’t been a mention of developing a naming convention that makes it obvious if a variable is a pointer or an actual variable. Something like ending all pointer names with an underscore
kid: "mom, can i watch shorts from harvard cs50?"
mom: "no, we have shorts at home"
*shorts at home - 30 minutes
I think it would be worth showing the "->" syntax for de-referencing struct properties.
youuuuu doug Lloyd help many peoples in brazil, thanks!
very useful video!
so helpful, thanks
arrays aren't just pointers. they are similar, but 1. they support different notation for accessing the memory they point to (no asterisk asterisk), and 2. you can't change the memory address an array variable holds, whereas you can change the address a pointer variable holds. when you pass an array to a function, the argument will be a pointer containing the same address the array points to, this is also referred to as an array "decaying into a pointer"
thanks Doug
please please please do some video on the difference between char *arr[] and char (*arr)[]
great video
Thank you sir
My mind exploded when he talked about 32 and 64-bit systems. Does that mean that the NES, an 8-bit system, can only store addresses (pointers) up to 0xFF?
I take that pointers work like global variables, since locally scoped variables cannot be changed outside of their scope. With a pointer you can access it and change it from anywhere just like you could do with a global variable ??
At 17:76 when you refer to the example on Variables and Scope, actually it was the example at the end of Arrays video! ruclips.net/video/YdSycMcxvY0/видео.html
I really should talk to my dean about hiring teachers like u, you are soo good in delivering the message
thank u i under stand
If you take the context out of it, that neighbor's house part is very funny
what data item is also used to hold the address of a pointer? Also why can't strings be used to hold the address of other variables sine the hexadecimal notation is a string
This is the only pointer tutorial that actually explains there are 2 uses of *
Is no one going to mention the little black dot flying back and forth on the screen starting around 15:12 ?
this one was good
question: at the end, when you said pk gets the address of m, does it mean the hex in pk then is changed to a whole new value?
lmao when ur uni prof doesnt explain anything, so u came to here !!! it was helpful thankyou
Thanks
BUT why do we use pointers at all. I mean why dont we just work with different variables at once but use pointer to point at an adress which in fact just takes the information stored in that adress its pointing at and stores in it self. Why dont we just use the Variable we point at in the first place. Thats the question I dont understand....
also, these are virtual addresses. C programs work under the assumption they "own" the entire memory space, and the OS gives them a fake memory address starting from 0 to make it simpler for individual programs, but the OS may allocate bytes, even those of an array, all over the place, and the conversion of virtual to physical space is done by the OS or CPU under the hood.
17:32 ain't arr[i] refer to the i+1 th element of the array? cause arr refers to the address of the first element, arr +1 to the second element and so on. correct me if I am wrong.
This videos awesome but somebody messed up the premiere export settings
I'm surprised I was this video's first like. This is great! Thank you.
Hello, I'm from the future here to tell you that you were not the first like, they have the likes disabled on this video so you cannot see the current number of likes.
Thank you.
@17:40 I don't see how the implication is that arrays names are just pointers. Like you made that leap.
When you say that "all pointers are just addresses", don't you really mean that all pointers are VARIABLES that hold an address? Otherwise it's too abstract. If I am understanding correctly, a pointer is not the address itself, but rather a memory location (represented by a *variable) that holds the "gps" coordinates(i.e. address) to a different memory location where the values (stored in binary) actually physically live in RAM world.
The way I've always thought about it is this. A pointer is just a variable. It would make no difference WHATSOEVER (if I'm not mistaken) if you say int p = &x , the star just tells the compiler that you INTEND to put some address inside that variable. Because at the end of the day it's just numbers, zeroes and ones, all a pointer is, is simply a variable that happens to hold zeroes and ones that represent an address in the memory rather than a value that you want to use directly
@@mohammedjawahri5726 Agree. It is just a variable that meant to be pointing an address in memory. But it is also stored in memory and it has its own address.
@@mohammedjawahri5726 Yeah, almost :) This here won't work "int p = &x" since the address of x isn't an integer. But in general I think you're right.
This is so much simpler and easier to understand(at least for me).
so * is not used to make something into a pointer? it is just used for dereferencing?
When you just finished watching a 2hr and 40 min video, just to watch another few hours more..
Oh god help me
Pointers aren't real, they are just addresses, they can't hurt you. CS50 problem set:
Does this apply to the Python pointers?
That was useful