Added: 3 years ago
From: StanfordUniversity
Views: 31,511
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:
see all

All Comments (28)

Sign In or Sign Up now to post a comment!
  • @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|
  • @blackcompe cool! thanks!

  • This guy is a genius. Clear as water.

    

  • 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

    lol... yeah man i know what you mean i feel the same way :P

  • @kaarta no casting needed because every pointer is a 4 byte wide

  • @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 you're right, thanks

  • Don't you need to cast the pointer returned by malloc to the type of elems i.e. (int *)?

  • He's got really good chalkboard handwriting and diagrams.

  • Is ths kinda like a SQL? file dumping and function control?

  • 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.

  • well thats not that bad...you know,

    real programmers compile using a magnet and a piece of metal. =D

  • 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.

  • xD very funny comment ;) THX for making me laugh, cheers.

    ps love the course on youtube, very educational!

  • 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 i thought the same thing..thanks..funny how nobody noticed during the lecture..

  • Comment removed

  • @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

  • I'd pay money to go to Stanford if I could if everything was of this quality. :)

  • Good stuff. I like this guy's enthusiasm.

  • great lecture.

  • ela ela

Loading...
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more