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

Link to this comment:

Share to:
see all

All Comments (110)

Sign In or Sign Up now to post a comment!
  • Brilliant teaching here, wish my school was as good(or my family rich enough for stanford).

    Also, does he sound like Nicolas Cage to anyone else?

  • WTF? Wouldn't ((char*)(&arr[1]))+8 bring him to &arr[3]? If the char is 1 byte, then you're moving 8 bytes from &char[1], which is two ints, which are each 4 bytes...

  • "does that make sence to people" not me -.-

  • It's just awesome.

  • Will this teach me to program C or C++ ?? Someone Please Answer

  • @KenmoreTownKillaz right now, C. later perhaps C++.

  • @KenmoreTownKillaz it will give you a lot, but to learn to program it isn't only learning programming language...

  • Respond to this video...  i guess to answer more precise to your question, this is not the place to start

  • what a great teacher! Way better than my comp science teachers in Eindhoven almost 20 years ago.

  • I've been trying to learn programming/scripting languages for a while.

    And because of my over-analytical mindset, I just couldn't 'get' half of it, so a good friend told me to look into programming principles.

    And finally, although I'm going to do CompSci at University, I am finally getting it. Thank you Stanford and Prof Cain.

  • I've learn all of this in my college, but he make it perfectly clear here :D I'm glad I find this course :D

  • Чёто я недопонял. На 29:30 от arr[1] нужно 8 раз сместиться на размер char, т.е 8 байт. Размер сигмента int т.е. 4 байта, а он смещается на 4 сегмента, т.е. 16 байт. Ошибся? Или я чё-то не вкурил...

    I have i little misunderstanding...On 29:30 we need to jump from arr[1] position 8 times on size of char (8*1=8bytes). Segment size is int (4bytes), but he jumps on 4 segments (4*4=16bytes). Mistake? Or its just me...

  • @AesmaDiv

    I think you just missed the arr[3].

    We move 8 chars forward first, then we change to using short (4bytes) as the segment size and move to the fourth segment because he is writing the value 100 to arr[3], the fourth entity in the arr array.

  • @AesmaDiv I was thinking the same thing.... He was traversing the array of integers as if each box were containing 2 bytes instead of 4 bytes (probably confusing them as shorts). After the (char *) type cast, he would end up with a pointer to the 4th "box", or arr[3].

  • @Ghouly89

    i agree, it should be &arr[3] or arr + 3

  • Yeah, it's a test. Everyone who commented on that is getting a scholarship to Stanford. Good job, you're in.

  • "double d" I see what you did there.

  • sure....makes sense, but let me rewind that anyway

    

  • "Don't write code like this, just understand it ! " 30:18

  • @ArturoDezaPeru

    Nice one! Mind sharing how?

  • Thumbs up when he said "x box", your first thought jumps to xBox.

  • "Does that make sense to people ?"

  • @selfdealloc , Yh He Always Say that, It's Was Funny To Me, Specially That He Emphasizes on it, HaHaHa

  • 1:55, self note

  • Degree is just one piece of paper, but knowledge that you have, is a real degree.

  • @devidsimon Yeah but you can't put 'I meet the requirements of such and such degree with knowledge' on your CV.

  • Comment removed

  • Something I found quite interesting. Stanfords german motto at the beginning of each video reads "Die Luft der Freiheit weht" which relates to Stanfords german heritage and translates as "The air of freedom is waving" or "The wind of freedom blows"

  • everything is Blue

  • How much does it cost to study @ Stanford per semester ?

  • he is a good teacher ... thanks uploader for sharing this video on the internet ....

  • Those are some huge chalks he's using

  • @imdando I saw one guy using one the size of a can of soda. They don't f**k around with their chalk selection.

  • I mean the first bit is 2 not each bit. I think the 2 is on or off because 2 to the 0 is 0 so you either have a 0 or a 2 to a power. These are Int's. so when you say int num1

    you store the char 1 in the int array. there are diff types of array. ones for numbers ones for signs, and so on. Yeah so it's kinda crazy.

  • You can take classes online. But yeah you need your Gen Ed first.

    This is Comp SCI 106 so they took like 4-5 computer classes before this one. Seems Linux is the OS people want to hire in. So this is useless in the real world. Java Scripting and Linux OS is a must. This guy is looking to program a chip or see what is on a chip. That is all this is. Knowing code and operations is the most important.

  • Any one know how he goes from 2 | 125 to 512+125 at 28:11? Thanks in advance.

  • @keylazy In an array, each bit is 2 to the first, then the next bit is 2 to the second and so on from left to right on the array. Array is a microprocessor. So when he wrote 2 in the array, he defined the array as a short, That basically doubled the size of the processor by dividing the bits in half. so when you count over 4 it is really 8. so its 2 to the 8th not 2 to the 4th// Now its 2 to the 8th and since 125 sits in the same space , the processor will multiply them.

  • @keylazy 125 is stored in the lower 8 bits and the 2 is stored in the higher 8 bits.

    So the 2 is actually 2^9=512. This is just the way he represents it on the blackboard. The | is there to show the separation between two bytes.

  • Guys, does this make sense?

  • Yeah Stanford is way better than MIT! Video and audio that is.

  • I love Mr. Cain. Yeah I am kinda keeping up. It's great to review on video like this. You won't miss parts of the lectures. Wish I have more background and knew some codes and so on. I know a little HTML but this is pretty advance, you got to start someplace I guess.

  • I should just erase with the chalk...

  • Does that make sense to people? OMG how many times does he have to say that. Maybe 100 times in just 3 videos. Jeez!

  • @ThExChAmP1 As many times as he needs to make sense to people. Make sense?

  • I loved it.

  • Comment removed

  • @29.28

    I don't think he added the chars up correctly. The boxes represent integers which are four bytes each, a char is 1 byte so from the second box he adds 8 char sizes onto it which takes him to the start of the fourth box ( the one with the 2 and 128 in it ). He then casts that as a short pointer and jumps three shorts in which is one short away from the end of the array ( halfway through the last box ) .

  • @Impresentation I think you're right. At 29:39, as he starts adding up the char offset of 8 he mistakes the boxes in his original array as shorts.

  • always amazes me how a computer works. each little pixel on the screen is referenced from a tiny little cell in a memory chip which is either On or Off.. i think.. (only know the basics)

  • @BINLASH123 Actually every pixel is always turned on. You just modify it's color.

  • Actually this is extremely structured. This entire lecture is about one single concept.

    31:00 was when my head exploded.

  • @ 41:31

    He's forgetting that he wrote character data, not numeric data, so the 3 in the first byte of numUnits is chracter '3' (value 51) not the number 3. He's also interpreting it as big endian when the computer's they're using are little endian.

  • Comment removed

  • You learned how to write generic vectors in C at community college?

  • Comment removed

  • @ILoveDogsandHarleys ILoveDogsandHarleysandCommunit­yCollege

  • Can someone help me figure out why this code doesn't do what I expect? It should display 5, right?

    int intArray[5];

    intArray[3] = 5;

    cout << ((short*)intArray)[7] << endl;

    For some reason, it doesn't. I used this line to check if these addresses were the same:

    cout << &((short*)intArray)[6] << " " << &intArray[3] << endl;

    And they are. I even used sizeof to see if ints were 4 bytes and shorts were 2, and they are.

    Any help would be appreciated.

  • Use subscript 6 instead of subscript 7 in your cout statement.

    If you want to know why, it's because Intel processors are "little endian" (Google it).

  • Heh, that's the one thing that I didn't think to check. Thanks.

  • It is because in memory of PC values are represented in such a way, so high byte is located as high address.

    For example value 5 of type int will be represented as 0x05 00 00 00 and value 5 of type short will be 0x05 00.

    So when you reference this ((short*)intArray)[7] , you actually reference to high byte of 3rd element, which is 00 00. To correct this, you must refer to 6th element of short: ((short*)intArray)[6].

  • Comment removed

  • Comment removed

  • I think at 29:41 he is making a mistake by thinking of the array as an array of 5 short's (2 bytes each) but really he declared an array of 5 int's(4 bytes each).

    I think the 100 would be placed in the last two bytes of arr[4].

    Anyone agree/disagree?

  • I totally agree. he would end up in the middle of the last box. He takes the size of the boxes to be 2 bytes, while they in fact are ints, so 4 bytes. Well noticed. I didn't notice it the first time I saw it. Thanks for pointing it out.

  • I agree. Where he went wrong was accidentally adding 16 onto the casted char* instead of 8 for the reason you said (mistaking the array for an array shorts).

    It's easy to make a mistake like this when trying to explain something with lots of numbers and multiple typecasting.

  • I agree, I noticed the same thing while I was watching.

  • OMG this is awesome. This teacher is coool. I want to go to Stanford :(

  • Comment removed

  • I am studding CS during last 5-6 years, but this video is a very informative for me, and I just only now understand how represent array, structures in the memory...

  • mcfalu. I'm having difficulty understanding function pointers. Can you tell me which of these videos covers this?

  • blue boards are way cooler than green.

  • Hey..maybe stanford university should give education for free so everyone else can learn through the computers...no? yes?..anyone?..does that make sense?

  • how would they make money if it was free

  • is not about the money, is about a message to the world, didn't you watch batman the dark knight??..

  • yes i saw that movie more times than anyone should, and i dont get how funding the education system and universities connects with it. perhaps you could explain a little bit more?

  • can't believe I gotta explain myself. The Joker at some point in the movie burns the money and cares for the message he want to send to the people of gotham. It connects in my sense that Stanford can be the Joker, and send a message of not caring about the money but about sending a message of altruism by sharing their fine education programs so others can follow. It doesn't have to be all programs, but some (like this one) could be enough..got me?? get out of my face..

  • if Stanford puts most of it's lectures on the internet for free, who's going to pay the teachers to keep teaching??

  • ooo see thats why i didnt get it-because it doesnt make any sense. the joker represents chaos and anarchy, and thats why he burns the money, because he has no use for it., where as stanford university has plenty use for money, and yes, they could give some education freely, like they are in this youtube video and thats exactly what their doing. i dont have a problem with that point, its your stupid analogy which confused me

  • Lol, you can't get a degree on youtube can you?

  • Sort of. A few people I know have used free education from MIT and Stanford to skip through a lot of undergraduate courses in areas such as math and computer science, and are now doing a combined BS/MS while taking a mix of undergraduate and graduate classes. So it kind of helps you get an undergraduate degree. But you still need to be in the school and paying for your education.

  • @c0lkowalski You should be able to :). The future of education perhaps? We can dream.

  • Comment removed

  • This is very good, but you should give him a better eraser :P

  • I'm more worried about giving him a dust mask...

    he's inhaling a lot of that crap..

    but he's really really good. he does not employ much jokes, but still makes the lecture interesting..

  • I'm just learning about C pointers and arrays right now and this is really making me understand. Great lectures. These and the old MIT "structure and interpretation of computer programs" lectures from 1986 (done in LISP) will make anyone a great programmer. You can download the MIT lectures somewhere as well, just Google them.

  • SICP is the bible.

  • "Does that make sense to people?"

    That's my new catchphrase. People are going to be SO SICK of me pretty soon.

  • thank you for sharing, but why are the high quality vids removed?

  • This is very informative and useful as a supplement to anyone's CS education.

  • Aren't the students at Stanford pissed about all these lectures being available for anyone?

  • better them pissed than every body else dumber.

  • thank you for sharing it

  • Thank you for posting these lectures, they are very clear and great for revising the basics from my uni days.

    Lately I work mainly with C# and I'm grateful to have a garbage collector cleaning up after me, but it's good to remember not to abuse it and write bloated code!

    Thanks Jerry.

  • Jerry is Excelent !!!!!!!!!!

  • Realmente todo lo explicado por el profesor Jerry Cain es fundamental ! si conoces esto es probable que no tengas muchos problemas incluso al implementar tu propio compilador o interprete! Excelente lecture.

  • this deserves a 10 star rating! really! how come i didn't see this earlier? Thanks for posting these, great lecturer :)

  • This is awesome. That's all there is to say.

  • yay free college on youtube!

  • Indeed, not too many views.

    I'm a Delphi programmer myself, but these kind of videos are helpfull even for a non-C programmer to be honest. Thank you Stanford!

  • He could have given a fuller response to the student who asked, why specify the size of an array if C is going to ignore it anyway? (at 19:30, array discussion at 15:45)

    The answer is that if you didn't then the memory locations you access in the array would be memory conflicts just as locations outside the array range.

    But that wouldn't really be a problem because the program wouldn't know where the array was anyway if it wasn't specified to begin with.

  • Yep, that would have been useful to mention.

    Also, the array declaration tells the compiler what data type the elements are, so it can do the pointer arithmetic for each indexed element. &chararray[1] == &chararray[0] + 1 byte, &intarray[1] == &intarray[0] + 4 bytes

  • does that make sense??

    hehe, the new running gag :)

  • These are great!

    .

    .

    .

    "Does that make sense to people?" ... lol

  • dam, the view counts for stanford are low!!

    it sucks that no one wants to learn!

  • It does suck. But if you want to be optimistic you can see that as less competition for us programmers.

  • yeah, your right!! let them learn their myspace, that going to get them far!!

  • Very good interpretation!!

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