@43:00 do you not have to deallocate the space that is supposed to be popped before exiting the stackpop function, since you used the 'memcpy' and not 'memcut' or something?
@zengrz No, because your going to memcpy() into that space on the next invocation of stackpush(). E.g. $ - bottom of stack $|2|1|3| logLength = 2 So, 3 is the last element in the stack. The client calls stackpop(). I don't need to deallocate or erase anything, just the return value and set logLength accordingly. $|2|1|3| logLength--; So, 1 is the last element in the stack. Now the client calls stackpush(7). I just overwrite the next element since its garbage. logLength++; $|2|1|7|
I don't know whether to feel happy this is free or saddened by the fact that I pay more to learn less from my university's IS program than I can learn off of YouTube.
@algnadjib That's not the reason why you don't need to cast the pointer.
What happens is that the compiler implicitly casts the void * returned by malloc to the pointer type you need, in this case an int *. If the pointer remains a void *, or a typeless pointer, then it doesn't matter if we know that all pointers are 4 bytes wide, because we still have NO idea how big the object it is pointing to is.
Does anyone else find it hilarious when Professor Cain is writing on the board and sings "dup de de duh" as a little vocal embellishment to the end of whatever line he's writing? He does it occasionally in all the videos and I always have to stop and laugh.
This has been flagged as spam show
Greatest method of programming I have ever seen.
grunder20 1 month ago
This has been flagged as spam show
Enthusiastic person
grunder20 2 months ago
@43:00 do you not have to deallocate the space that is supposed to be popped before exiting the stackpop function, since you used the 'memcpy' and not 'memcut' or something?
zengrz 5 months ago
blackcompe 5 months ago
@blackcompe cool! thanks!
zengrz 5 months ago
This guy is a genius. Clear as water.
rakolman 7 months ago in playlist Course | Programming Paradigms
I don't know whether to feel happy this is free or saddened by the fact that I pay more to learn less from my university's IS program than I can learn off of YouTube.
bluetoothEnabled 10 months ago
@bluetoothEnabled
lol... yeah man i know what you mean i feel the same way :P
yoyuepz 10 months ago
This has been flagged as spam show
Don't you need to cast the pointer returned by malloc to the type of elems i.e. (int *)?
kaarta 10 months ago
@kaarta no casting needed because every pointer is a 4 byte wide
algnadjib 6 months ago
@algnadjib That's not the reason why you don't need to cast the pointer.
What happens is that the compiler implicitly casts the void * returned by malloc to the pointer type you need, in this case an int *. If the pointer remains a void *, or a typeless pointer, then it doesn't matter if we know that all pointers are 4 bytes wide, because we still have NO idea how big the object it is pointing to is.
Ghouly89 3 months ago
@Ghouly89 you're right, thanks
algnadjib 3 months ago
Don't you need to cast the pointer returned by malloc to the type of elems i.e. (int *)?
kaarta 10 months ago
He's got really good chalkboard handwriting and diagrams.
dacherx 1 year ago
Is ths kinda like a SQL? file dumping and function control?
silverpizza100 1 year ago
Does anyone else find it hilarious when Professor Cain is writing on the board and sings "dup de de duh" as a little vocal embellishment to the end of whatever line he's writing? He does it occasionally in all the videos and I always have to stop and laugh.
DisgustingArsehole 1 year ago 2
well thats not that bad...you know,
real programmers compile using a magnet and a piece of metal. =D
krisdestruction 2 years ago
I bet when this guy is working on a project, he still codes in chalk, and then compiles it by hand.
He does this by attaching small magnets to the end of his fingers, then waves them over the hard drive.
Interesting stuff, will keep watching.
DuckshotThePig 2 years ago
xD very funny comment ;) THX for making me laugh, cheers.
ps love the course on youtube, very educational!
glashopper 2 years ago
At 29:00 assert(s->elemsize > 0) should be assert (elemsize > 0) because s->elemsize is not yet attributed to elemsize, so there is garbage in it.
glcrazy 2 years ago 19
@glcrazy i thought the same thing..thanks..funny how nobody noticed during the lecture..
Dankolix 1 year ago
Comment removed
Dankolix 1 year ago
@glcrazy i think that was a typo.. he wanted to check elemSize not s->elemSize, to make sure it was not 0 before he set it to s->elemSize
ZyberWaX 2 months ago
I'd pay money to go to Stanford if I could if everything was of this quality. :)
Devourer09 2 years ago
Good stuff. I like this guy's enthusiasm.
region1111 2 years ago 9
great lecture.
stayyabali 2 years ago
This has been flagged as spam show
Jerry makes me laugh at 13:15
NameNotaNumber 2 years ago
ela ela
OneSrilanka4all 3 years ago