CS50x 2024 - Lecture 4 - Memory

Поделиться
HTML-код
  • Опубликовано: 25 дек 2024

Комментарии • 209

  • @MasterOfYourself
    @MasterOfYourself 8 месяцев назад +187

    I love how David is really trying to hear people's questions, and he encourages them with cookies, or jokes.

    • @kent1k359
      @kent1k359 6 месяцев назад +3

      Best educator imho

  • @Aprokind
    @Aprokind 6 месяцев назад +229

    If you are reading this, I hope you finish cs50 and go on to do well in whatever endeavor you choose.

    • @thebrightchannel6898
      @thebrightchannel6898 4 месяца назад +6

      I will and i hope you will to, good luck!

    • @goldfirstman5727
      @goldfirstman5727 12 дней назад +1

      Thank you so much. I gave up on CS50 for awhile due to other things but seeing this post, I feel I should get back on it. Thank you

  • @BerkGoknil
    @BerkGoknil 8 месяцев назад +39

    Even if you have been writing programmes for 20 years, it is an excellent series that must be completed to the end. Thank you David and Harvard.

  • @worrystone
    @worrystone 11 месяцев назад +86

    Feeling honored to experience buffer overflow during the overflow section.

  • @meegel
    @meegel 11 месяцев назад +161

    Theres a lot of "A-HA" moments for me this week, it is incredibly motivational for me to keep on learning CS. Thank you Professor Malan and the CS50 team!

  • @kurrizzle
    @kurrizzle 9 месяцев назад +66

    that little disappearing magic trick at 1:28:20 was subtle but nice

  • @yasinarafat7999
    @yasinarafat7999 24 дня назад +2

    21:15 Pointers 24:40
    43:38 & is the address of a variable.
    45:19 typedef
    1:15:55 NULL means "address zero", "error".
    1:21:28 writing means "changing information", like setting a value or assigning it a value.
    1:22:30 memory leak
    1:30:30 at first "pointer", then "pointee", and then "dereferencing".
    1:36:00 passing by value == passing by copy
    1:40:55 passing by reference == passing by pointer
    overflow 1:46:27 stack overflow, heap overflow
    overflow 1:48:08 buffer overflow
    overflow 1:48:49 buffer overflow
    1:54:55 clang
    1:55:40 segmentation fault (core dumped)
    1:59:10 segmentation fault (core dumped)
    2:02:32 some common functions for file i/o
    2:09:35 uint8_t
    2:10:50 binary mode

    • @BestHomeOman
      @BestHomeOman 7 дней назад

      THANKS

    • @BestHomeOman
      @BestHomeOman 5 дней назад +1

      2:12:20 copy files
      fread(address of where to load, how big is the byte, how many bytes do I wanna copy at a time, where do I read those bytes from aka source)
      fwrite(address of where to write, how big is the byte, how many bytes do I wanna copy at a time, where do I write those bytes to aka destination)

    • @yasinarafat7999
      @yasinarafat7999 5 дней назад +1

      @@BestHomeOman most welcome

  • @codewithsajid
    @codewithsajid Год назад +72

    for those scratching your head at 49:20, perhaps this will help.
    what is the relationship between arrays and pointers/addresses?
    ---
    In C, arrays and pointers are closely related. Here's a breakdown of their relationship:
    1. Array Name as a Pointer: When you define an array in C, the array name acts as a pointer to the first element of the array. For instance, if you have int arr[10];, arr can be thought of as a pointer to arr[0].
    2. Pointer Arithmetic: You can perform arithmetic on pointers just as you can with arrays. When you increment a pointer that points to an array, it points to the next element of the array. This is because the size of the type the pointer points to is considered in the arithmetic.
    3. Indexing: You can access elements of an array using the subscript notation []. Under the hood, this is converted to pointer arithmetic. The expression arr[i] is equivalent to *(arr + i). This means "get the value at the address arr plus i times the size of the array's element type".
    ---
    Thanks chatgpt

  • @BestHomeOman
    @BestHomeOman 7 дней назад +1

    21:15 Pointers 24:40
    43:38 & is the address of a variable.
    45:19 typedef
    1:15:55 NULL means "address zero", "error".
    1:21:28 Writing means "changing information", like setting a value or assigning it a value.

  • @randomforest_dev
    @randomforest_dev 9 месяцев назад +15

    CS50 2024 lectures are really awesome!

  • @amirabdelli2295
    @amirabdelli2295 Год назад +47

    Starting 2024x here as this is where I was in the 2023x series (and I could definitely benefit from rewatching this one)

  • @DRNOval
    @DRNOval 3 месяца назад +13

    finally got thru tideman after a week and a half of struggle and am so happy to be watching this finally 😭😭

    • @krish-ut9de
      @krish-ut9de 3 месяца назад +1

      lol me too, gl for this week's assignment

    • @emmanuelprudente6463
      @emmanuelprudente6463 Месяц назад

      Lmao exactly same for me over here.
      See you around folks!

    • @DRNOval
      @DRNOval Месяц назад

      @@emmanuelprudente6463 im on week 7 now, as long as u can push past week 5 it gets easier after it seems

    • @db2360
      @db2360 Месяц назад

      I have cried as well. A lot. 😂 (And ddb helped a LOT)

  • @Hermeticoh11
    @Hermeticoh11 10 месяцев назад +6

    Thank you, David, for your amazing teaching skills! I can't believe I'm being able to understand aaaaall this information having started learning computer science this year

  • @FigueMonk
    @FigueMonk 6 месяцев назад +8

    I am here after trying to understand lecture 5. Probably is good idea to refresh these lecture's concepts. Keep learning folks, one day at time, step by step

  • @hmmmzaDev
    @hmmmzaDev Год назад +18

    I was just watching the lecture 4 of CS50-2023x and during the break, I have stumbled onto this video. Not sure now if I should continue watching that one or start from here again.

    • @harppsricprince
      @harppsricprince Год назад +1

      Same thing with me. That’s exactly what I am thinking

    • @user-yk1cw8im4h
      @user-yk1cw8im4h Год назад +2

      u r just into lecture 4… of course continue with this

    • @Kampouse
      @Kampouse 11 месяцев назад +3

      its same content only a news "version"

    • @andoryu14
      @andoryu14 10 месяцев назад +2

      the 2024 versions are almost exactly the same and the course itself now asks you to do the 2024 version, and carries over progress from 2023

  • @realJaeyongLim
    @realJaeyongLim 11 месяцев назад +36

    I started CS50 since 2021 but did not make it to the endpoint. Now I have decided to resume it while serving at the military. I really love watching Professor Malan's lectures:)

    • @Senko1800
      @Senko1800 11 месяцев назад +4

      YES , keep it up champ🏆

    • @brandoncarris9015
      @brandoncarris9015 5 месяцев назад

      thank you for your service !!!

    • @michaelphilps
      @michaelphilps 3 месяца назад

      Don't kill innocent people.

  • @jiayiweng8985
    @jiayiweng8985 Месяц назад

    22:58 pointers - getting the address(&n) of the integer stored in memory
    24:11 pointers - getting the integer of that address

  • @naboulsikhalid7763
    @naboulsikhalid7763 6 месяцев назад +1

    I am overwhelmed by the info introduced and very glad to know it and move with my C computing and programming. Thank you David

  • @ProudyShankalpa
    @ProudyShankalpa 6 месяцев назад +5

    can't wait to solve the assignment with these new tools. thank you david and whole cs50 team

    • @hawamigil4291
      @hawamigil4291 5 месяцев назад

      What about tideman

    • @TheIonizator
      @TheIonizator 5 месяцев назад

      @@hawamigil4291 pls no

    • @pikmintopia
      @pikmintopia 8 дней назад

      @@hawamigil4291 we dont talk about tideman

  • @rida_brahim
    @rida_brahim 11 месяцев назад +10

    there is something guys about changing the string s to char *s, if you do this without the cs50.h you can't change the value of a char in a string, i was going back and forth with chatgpt until i tested it myself, even if professor david changed string s to char *s the actual string which is "Hi!" cannot be changed by trying to change char H like this : s[0] = 'h'; , you're probably asking yourself why and it's because the get_string function is returning an actual array that we store it's address in char *s and not the same thing when creating a string on the fly with the pointer, two different things, if you're creating a string on the fly without using [ ] to tell C it's an array you won't be able to change the characters in the string, I'm telling this to anyone got stuck with this asking himself this question, professor david probably didn't reveal this so things doesn't escalate quickly and I'm only 55min in so probably he's gonna reveal it later.

    • @ethylmusic
      @ethylmusic 10 месяцев назад +6

      string literal vs string in array is the reason for this. the former is immutable

    • @rida_brahim
      @rida_brahim 9 месяцев назад +2

      @@ethylmusic yeah, at the time it took me a while to get this while the compiler kept giving me errors then i found out it's read only and can't change it until i copy the string to an actual allocated memory and it seems that the get_string function actually does that.

  • @davidestadilla8271
    @davidestadilla8271 11 месяцев назад +8

    Just want to add something on pointer arithmetic.
    If you had a pointer to an integer (which consists of 4 bytes) and allocate memory for two integers and for some reason, you want to put values in it using the dereference (*) symbol, you should not do the following:
    int *n = malloc(sizeof(int) * 2)
    *n = 1
    *(n + 4) = 2 or *(n + sizeof(int)) = 2
    Instead, you should do this:
    int *n = malloc(sizeof(int) * 2)
    *n = 1
    *(n + 1) = 2
    No need to type in the quantity of bytes for the specific data type (in this case, it's 4 since it's an integer). C already knows that.

    • @a23oj28
      @a23oj28 9 месяцев назад

      Is this the same as an array of ints but just dynamically allocated?
      Does C know because of the type (int) that n points to or does it infer from the argument of malloc()?

  • @user-sb5vt8iy5q
    @user-sb5vt8iy5q 3 месяца назад +7

    In the file I/O section at the end, you're probably wondering, how did he call fwrite(...) in a loop, without it overwriting the first byte every time, shouldn't he have some sort of byte counter? I think they should consider mentioning this in cs50 2025 and onwards, essentially, the type "FILE* ", which is a file pointer, secretly holds a byte counter, so whenever you use fwrite, or fread, or similar, C will remember how many bytes you read or wrote, and it will keep track of it for you, just to clear up the confusion. TLDR: C keeps the number of bytes written/read to files for you, so you don't have to count, and that's why it works in loops, it automatically increments itself.

    • @zeshenzheng
      @zeshenzheng 3 месяца назад +1

      Thanks!You answer my question.

    • @user-sb5vt8iy5q
      @user-sb5vt8iy5q 3 месяца назад

      @@zeshenzheng np!

    • @gharial3234
      @gharial3234 Месяц назад

      This is why fseek() exists. If you want to read from a file multiple times, you need to manually fseek to the start of the file, otherwise it'll just pick up where you left off (giving you nothing if you read the entire file the first time around).

  • @kaunglin8447
    @kaunglin8447 6 месяцев назад +1

    I love you David. You are such a wonderful teacher.

  • @thezaytunpeach
    @thezaytunpeach 10 месяцев назад +16

    That was a PHENOMENAL lecture but brother did it escalate...

  • @jonnysegway7866
    @jonnysegway7866 2 месяца назад

    1:09:55 could also write 'for (int i = 0, n = strlen(s) + 1; i < n; i++)' as per for malloc

    • @gharial3234
      @gharial3234 Месяц назад

      Are you talking about calling malloc() in a loop that goes from 0 to strlen(s)?
      Firstly, that'll allocate 0 bytes, 1 byte, 2 bytes...strlen(n) bytes, which is not what you want.
      Secondly, there's no guarantee that those bytes will be contiguous, so doing:
      char *s = malloc(1);
      char *t = malloc(1);
      char *u = malloc(1);
      will not create a string that can be subscripted, as s, t, and u may not point to adjacent memory locations. What will work is:
      char *s = malloc(3);
      giving you 3 adjacent bytes in memory.
      Hope this helps!

  • @Lvbzzzz
    @Lvbzzzz Месяц назад

    2:13:53 I even copied source code from cp.c and still have an error "segmentation fault (core dumped)". what`s wrong?

  • @jonathanconnelly6993
    @jonathanconnelly6993 5 месяцев назад +10

    Must finish before the end of summer…. Must finish before the end of summer….. keep going …

  • @The.Oh1183
    @The.Oh1183 6 месяцев назад +41

    Please tell me I'm not the only one whose brain collapsed...

    • @mohammadsuhaanhaq3590
      @mohammadsuhaanhaq3590 6 месяцев назад +5

      you are not my brain also got fried

    • @MeowMuscleTv
      @MeowMuscleTv 5 месяцев назад +6

      you not alone it diffucult for me too but don't give up !!

    • @DizzyBusy
      @DizzyBusy 5 месяцев назад +1

      No, I had to distract myself with the Euro Cup for a bit before coming back to this week's PSET

    • @AdityaWilson
      @AdityaWilson 5 месяцев назад +3

      Welcome to the gang

    • @justarandomdude2489
      @justarandomdude2489 26 дней назад +2

      😂😂😂

  • @xavier2586
    @xavier2586 4 месяца назад +1

    Thank you so much Professor Malan.

  • @spicywe1ner
    @spicywe1ner 2 месяца назад

    Memory in C, Always the fun part.. Fantastic job as always.

  • @jonnysegway7866
    @jonnysegway7866 2 месяца назад +1

    1:00:00 my pc uses the same address for both! apparently the compiler knows the strings are the same and uses an optimisation technique known as 'string interning'!

  • @CườngNguyễnPhú-n2i
    @CườngNguyễnPhú-n2i 6 месяцев назад

    what an energetic teacher. Thanks David

  • @fardinkhandaker3436
    @fardinkhandaker3436 2 месяца назад

    I hate that I wasn't able to be there in person but thank you to those of you who were there and asked those great questions (some which were what I wanted to know about)!

  • @jonnysegway7866
    @jonnysegway7866 2 месяца назад

    2:00:00 can also limit the scanf input, but means you have to statically declare the char array first, which may be limiting/wasteful of memory i.e. *_char c[100];_* then *_scanf("%99s", s);_*

  • @oanhtuan2408
    @oanhtuan2408 8 месяцев назад

    Love it again ❤ Thank you, David! This lesson teaches me how we can efficiently open a file by using just its first address.

  • @virendxr
    @virendxr 11 месяцев назад +7

    21:17 so a pointer is simpy a varible which stores the memeory address of some other variable inside the variable called pointer . So do pointer variables* also have their own address? and can the adrees of pointer variables can be stored in another pointer variable?

    • @andrewpolakaus
      @andrewpolakaus 11 месяцев назад +14

      Yes. Examples:
      // x is a char
      char x;
      // y is a pointer to a char that stores the address of x
      char *y = &x
      // z is a pointer to a pointer to a char that stores the address of y.
      char **z = &y

    • @virendxr
      @virendxr 11 месяцев назад +1

      @@andrewpolakaus woh that's nice, thanks!

    • @ZerubbabelT.
      @ZerubbabelT. 7 месяцев назад

      @@andrewpolakaus Why double astrex on z?

    • @andrewpolakaus
      @andrewpolakaus 7 месяцев назад +5

      ​@@ZerubbabelT. that's a great question!
      If we declare "char x" then x is of type "char" i.e. x can store a char.
      Now iff we declare "char *y" then y is of type "pointer to a char" i.e. y can store the address of a char.
      And finally, if we declare "char **z" then z is of type "pointer to a pointer to a char" i.e. z can store the address of something that stores the address of a char.
      Each star add a level of indirection.

    • @ZerubbabelT.
      @ZerubbabelT. 7 месяцев назад

      @@andrewpolakaus Got it. Thanks

  • @berkaycirak
    @berkaycirak 8 месяцев назад +1

    56:12, I have a question about comparison. While we comparing two string, we compare its first char's addresses. Also, while we comparing two integer, why didn't we compare its addresses? I thought, while comparing two equal integer, their addresses will be different. For example, int n = 5; int x=5; . There will be two different addresses for n and x, and if we compare addresses they must be different

    • @sagarpanwar2845
      @sagarpanwar2845 8 месяцев назад +2

      because in int we compare their values not their address, because in string your variable contain a address of the first char and in int your variable contain a integer not their address.

  • @illillillill
    @illillillill 10 месяцев назад +2

    how wonderful teaching skill

  • @harizhakim5983
    @harizhakim5983 6 месяцев назад +2

    the toughest lecture and problems for me so far!

  • @bpopphixo9627
    @bpopphixo9627 4 месяца назад

    each video introduction: All right . This is CS50 LECTURE 3: ALGORITHMS

  • @Cadeyrnyes
    @Cadeyrnyes 3 месяца назад +1

    The duck actually taught me a bit of this in the Substitution pset 😂

  • @_allegra
    @_allegra 11 месяцев назад +8

    1:34:17 Caleb missing the opportunity to down one of the glasses and demonstrate clearing the memory allocation

    • @muhammadmx
      @muhammadmx 11 месяцев назад

      that would have not kept the original glasses swaped

  • @josephlevin
    @josephlevin 2 месяца назад

    Love the lecures. Had to laugh at "mostly just an excuse to use the foam fingers."

  • @csanders429
    @csanders429 3 месяца назад

    In the Tideman Algorithm swapping is by reference instead of value. When you’re working array indices, you’re essentially working with the actual memory locations - the entire structure no need for pointers; not basic variables `int`… The array elements hold the data. Know the difference between [Passing by Value] and [Passing by Reference].

  • @AgrimaSingh-w9d
    @AgrimaSingh-w9d Месяц назад

    29:42 opening the mailbox (pointer) and using * -- go to that location and show me what is there

  • @GenZ_01_
    @GenZ_01_ 5 месяцев назад

    Pure gold. Thank you Cs50 team

  • @sulikns4152
    @sulikns4152 5 месяцев назад

    Yeah David you are great man! thanx a lot🙏🏻

  • @gatephysicsnptellivevideoi5495
    @gatephysicsnptellivevideoi5495 3 месяца назад

    14:19 Does that mean each pixel consume 8-bit or 1 byte of memory?

  • @sibusisomakema7718
    @sibusisomakema7718 10 месяцев назад +1

    glad to see that the training wheel joke landed this year😂

  • @ares1647
    @ares1647 6 месяцев назад

    At 38:45, why put & before s[0] when it was not necessary in a line above and it still worked ? Also, printf format specified we're looking for an address with "%p".

    • @shubhamshetty3918
      @shubhamshetty3918 6 месяцев назад

      Correct, Both are the same & points to the same address, the first one just points to the first address as a whole while the other points out to the address of the first char in that array. Hope it gives more clarity.

    • @peterkarkosch3572
      @peterkarkosch3572 17 дней назад

      Had the same question. why is & even needed if not in line 7 before the s needed

  • @AuroraClair
    @AuroraClair 2 месяца назад

    2:06:36 line 12 - shouldn't we have deregerenced the name and number? Or does the fact that we used %s return the dereferenced pointer already?

    • @jonnysegway7866
      @jonnysegway7866 2 месяца назад

      if I may, char * array (or any array) is an exception to that rule, no need to de-reference

  • @ilove0908
    @ilove0908 5 месяцев назад

    Very useful lecture. Thanks a lot !!

  • @mattybadger13
    @mattybadger13 8 дней назад

    Gotta be honest, using the CS50 library is more than "training wheels", it hinders anyone not actually in CS50. Learning about char *s was fantastic but then immediately get_int screws the whole thing up again. Scanf kind of works but doesn't allow for different integers. Fantastic course, so happy it exists, but this was the first project in 4 lessons I've been able to ACTUALLY do. Kind of.

  • @ZerubbabelT.
    @ZerubbabelT. 7 месяцев назад

    21:02 Why am I not getting hexadecimal number?Instead its decimal number

  • @deutschWallah
    @deutschWallah 7 дней назад

    Just superb!

  • @shrutisinghal2490
    @shrutisinghal2490 7 месяцев назад

    Thank you Sir, for amazing teaching😃 will be always thankful for giving us CS50

  • @brownie2006
    @brownie2006 8 месяцев назад +1

    I LOVE CS50

  • @nbtwall7287
    @nbtwall7287 7 месяцев назад

    27:19 Professor Malan said the memory address 'p' is storing an integer. Are memory addresses signed? does the computer track negative spaces in memory?

    • @shiny5176
      @shiny5176 7 месяцев назад +1

      addresses are unsigned integers

  • @CygnusX-11
    @CygnusX-11 2 месяца назад

    Brilliant teacher

  • @aopen130
    @aopen130 9 месяцев назад

    36:18 oh 32 bit max out at 2 billion addreses. So that's why the FAT32 doesn't go very high in partition like exFAT. Makes sense.

  • @proudathiest
    @proudathiest 6 месяцев назад +2

    If the computer needs a pointer (s) to go to the address of the first char, how does it find s in memory to get to the char?

    • @mosstah
      @mosstah 6 месяцев назад

      It stores and accesses the pointer in the same way it accesses any other variable, such as storing a char without bothering with any pointers. However, if the pointer was replaced with a simple char variable, the computer would only return that character and wouldn't know to look for the rest of the values in the string which is why the pointer is necessary.

    • @proudathiest
      @proudathiest 6 месяцев назад

      @@mosstah But how does it access any variable? If I write int x = 10, and then use x later in the code, how does it find that x is 10?

    • @gabrielangel1996
      @gabrielangel1996 2 месяца назад

      ​​@@proudathiest for local memories, it stores on the stack part of the memory. The CPU store the last adress of that stack. The compiler only needs to remember how much you push the stack memory. Imagine a shelf, you put one book, then another on top, and so on. And you write how many books you stacked. Well, if you want the first book(variable) you just have to go down for how many books you put on top of it. The compiler does that for you. Hope you got what im saying

    • @proudathiest
      @proudathiest 2 месяца назад +1

      @@gabrielangel1996 Thankyou! I've just spent an hour looking at stack pointers and it finally makes sense!

  • @krish-ut9de
    @krish-ut9de 3 месяца назад +1

    i suddenly feel like a real programmer now

  • @isekesmiyake3891
    @isekesmiyake3891 Месяц назад

    I am a litle bit confuse here. So we create an variable called pointers that contains an adress where a value of an other variable is stored ok? But the pointer has also an adress rigth? for me, all of this seems to lead to an infinite spiral of adresses. May someone help me

  • @nicovulpus
    @nicovulpus 7 месяцев назад

    @42:32 David says that *s is the address, but isn`t it actually a pointer to the first character in the character array?

    • @Marco-sm9bu
      @Marco-sm9bu 6 месяцев назад

      yes, &s is the address

  • @SyariefAzman
    @SyariefAzman 3 месяца назад

    im confused about the usage of star and ampersand. for example *s is a pointer pointing to the address in the memory . but &s pointing to the memory adress too? what is that ?

  • @riyajath_hmd
    @riyajath_hmd 11 месяцев назад +9

    I lost my streak of watching one lecture per day, but I convinced myself to resume watching from where I left off. Today, I finished watching lecture 4 and I am determined to complete CS50 by the first week of February. After that, I plan to solve the problem sets and then I am thinking of learning JavaScript next.

    • @urosuros2072
      @urosuros2072 10 месяцев назад +6

      no one cares

    • @davidoffonly
      @davidoffonly 10 месяцев назад +7

      ​@@urosuros2072 hahahaha don't be that harsh man lol

    • @riyajath_hmd
      @riyajath_hmd 9 месяцев назад +5

      @@urosuros2072 did I ever mentioned your name and said that, if you don't like it just leave dude

    • @emer0r1a
      @emer0r1a 5 месяцев назад

      That's also what I'm doing! I try hard not to fall asleep lol

    • @123_wowowowowo
      @123_wowowowowo 5 месяцев назад +6

      Doing the problem sets right after the lectures would be a better idea because your brain is still fresh with knowledge from the lecture.

  • @siraniwaysdamelon
    @siraniwaysdamelon 2 месяца назад

    this was the final boss level for me

  • @BaibhavDeka
    @BaibhavDeka 11 месяцев назад +2

    best week of C i bet

  • @kmlime
    @kmlime 11 месяцев назад +4

    I miss the old intro 😢 but the course is amazing regardless

  • @dxdx7961
    @dxdx7961 4 месяца назад

    hello I have a question 43:00 char *s and char s[] is the same ?

    • @sein349
      @sein349 4 месяца назад

      char *s points at the first (0th) location of the string. Which means the string will be read from that location till the null (\0) to highlight the whole string.
      Meanwhile char s[] highlights the whole string (list of chars) right away.
      hope this helped

  • @OkuEfiong
    @OkuEfiong 5 месяцев назад

    Please what kind of VScode is David using, because my VScode terminal is not working?

  • @adnancodesweb
    @adnancodesweb 4 месяца назад

    I listen to this to go to sleep.. This is where I go to when I drift away and start day dreaming 😆

  • @Ahoora-o2v
    @Ahoora-o2v 3 месяца назад

    Hello, I have a question. I want to know whether Zig language can be better than Rust or not, and why Rust has been getting so much hate for some time now, and what is your opinion about Zig or Rust or C for creating very bad malware?

  • @lookalivebrett
    @lookalivebrett 9 месяцев назад

    Is it convention or preference to say "oh" when encountering a zero?

  • @regularnick
    @regularnick 6 месяцев назад +1

    it's kinda sad that he didn't explain with the code how the CS50 get_string actually works. Unfortunately, for now this is the only training wheel I can't take off

    • @clarerussell1
      @clarerussell1 6 месяцев назад +1

      It's explained in previous lectures. If you check out their library you will see how get_string works

    • @JAVPindia0
      @JAVPindia0 5 месяцев назад

      Did you mean playlist? When you say library or that's something different from that?​@@clarerussell1

    • @DizzyBusy
      @DizzyBusy 5 месяцев назад

      I second the previous comment. Just go to the library to see what get_string actually is

  • @tibetje226
    @tibetje226 3 месяца назад

    1:53:08 I started sweating when he said 'string input'.

  • @MD.NAZIMHOSSAIN-e2h
    @MD.NAZIMHOSSAIN-e2h 27 дней назад

    I believe Mr. Malan deserves AC!

  • @zinmyolatt1386
    @zinmyolatt1386 3 месяца назад

    I also tried to copy (int) instead of string and I found that the original and the copy don't exist in the same location.Why is that?
    int s = get_int("s: ");
    int t = s;
    printf("%p
    ", &s);
    printf("%p
    ", &t);

    • @jonnysegway7866
      @jonnysegway7866 2 месяца назад

      you are not using pointers, everything is being determined statically at compiliation - those variables will be in the stack instead of at run time/dynamically in the heap

  • @KiraIsGod
    @KiraIsGod Месяц назад

    there is a hidden message on the raw file for the recover problem from the problem set :)

  • @not_amanullah
    @not_amanullah 6 месяцев назад

    Thanks ❤

  • @wecode007
    @wecode007 11 месяцев назад +2

    wanted to study at harvard; but failed; dont worry we have david

  • @kenlow4048
    @kenlow4048 8 месяцев назад +1

    mind blowing

  • @nicovulpus
    @nicovulpus 7 месяцев назад

    How is p an integer when it contains alphabetical values?
    Like 0x123 has 'x' in it`s value?

    • @ninjamar_
      @ninjamar_ 7 месяцев назад +1

      0x123 is hexadecimal, which is a type of notation for numbers

    • @mosstah
      @mosstah 6 месяцев назад +1

      @@ninjamar_while this is true for the “123” part, the 0x isn’t a part of the value and is just standard convention for indicating that the following number is hexadecimal

    • @ninjamar_
      @ninjamar_ 6 месяцев назад

      @@mosstah yeah, it helps distinguish between decimal

  • @yunleung2631
    @yunleung2631 7 месяцев назад +1

    Must review notes. I barely understood the lecture

  • @vicetwice
    @vicetwice 8 месяцев назад

    Professor Malin is an actual robot

  • @beningsurya7479
    @beningsurya7479 2 месяца назад

    "It turns out that understanding pointers is not as terrifying as in previous years.

  • @sinajps378
    @sinajps378 8 месяцев назад

    i have a doubt . Why dont we use *s instead of s to print out the string

    • @DizzyBusy
      @DizzyBusy 5 месяцев назад

      That was explained in the "Strings" chapter of the video

  • @PedroAugustoMarquesFontoura
    @PedroAugustoMarquesFontoura 2 месяца назад

    01:46:00

  • @100drips
    @100drips 5 месяцев назад

    after 3 weeks of trying to solve tidemen, i can finally watch this lecture :D

    • @RameezRassel
      @RameezRassel 5 месяцев назад

      hey mah i spend like 16 hours on it and i gave up . i am not able to do the last 2 functions. i dont even have an idea on how to do it. You got any advise for me?

    • @100drips
      @100drips 5 месяцев назад

      @@RameezRassel 16 hours is nothing, haha 😅
      Here was my idea, that finally worked:
      To detect a cycle, look, if the loser of the pair you are trying to lock is a winner of an already locked pair. If so, is the winner of the pair you are trying to lock the loser in the locked pair? When this is the case, you've detected a very simple cycle. For example, when A is winner over B in the first locked pair and you try to lock in B over A. This is obvious and fairly simple.
      But if the winner of the pair you are trying to lock is not the loser, you have to check the next pair down the line. So in this case, look if the loser of the first locked pair is the winner of another locked pair. If so, does the loser of this pair equal the winner of the pair you are initially trying to lock in? If yes, a cycle is detected. If not, look for the next locked pair. Hint: a recursive function is very useful for this.
      I actually did a few exercises with recursion beforehand to really wrap my head around the concept.
      Good luck, you can do it!

    • @RameezRassel
      @RameezRassel 5 месяцев назад

      @@100drips hey thanks a lot mahn. Really Appreciate it. I was doing my research and it turns out there is an algorithm for traversing throughout graphs. It's called DFS I tried learning it but couldn't wrap my head around it . I think I understand ur logic now I have to code it. We'll see

    • @thebrightchannel6898
      @thebrightchannel6898 4 месяца назад

      @@RameezRassel Bro were you able to code it?

  • @codeandtech77
    @codeandtech77 4 месяца назад

    I don't really get what the function "malloc ()" really does. Anyone who understands this concept please help me to understand it too.

    • @hritviksoni6080
      @hritviksoni6080 4 месяца назад +3

      okay ! ill try to explain it, simply put , malloc is a function defined in header file , simply like printf is defined in and get_int defined in , its job is to allocate some space from your memory for you to do something on it for example store some data. Consider these statements 1. char *s = get_string("s: "); 2. char *t = malloc(string length (s) + 1); --> 1. gets string input from user and stores it in s --> 2. allocates memory of string length+1 (+1 to store \0 which signifies the end of a string ) for you to do something in the allocated memory from your storage.

    • @codeandtech77
      @codeandtech77 4 месяца назад

      @@hritviksoni6080 Thanks a lot! Appreciate your kindness. I kind of didn't understand this line: " gets string input from user and stores it in s --> 2" .

  • @licnex
    @licnex 2 месяца назад

    this entire week has just been a sequence of "huh?"s

  • @tibetje226
    @tibetje226 3 месяца назад

    1:31:34: 'ye sharing, whatever' LOL

  • @BonnieByte
    @BonnieByte 11 месяцев назад

    Very interesting

  • @licnex
    @licnex 2 месяца назад

    phase 1) pointers huh
    phase 2) I feel dead inside

  • @Sad_Chief
    @Sad_Chief 2 месяца назад

    1:16:43

  • @murrigo
    @murrigo 7 месяцев назад +1

    1:43 "or a jif or a ping"... David... my stars I almost stopped watching

  • @Naoty_san
    @Naoty_san 11 месяцев назад +1

    30:43

  • @RobertMooney-ut7cc
    @RobertMooney-ut7cc 3 месяца назад

    Muito obrigado. / Merci beaucoup.

  • @gamerdenver7811
    @gamerdenver7811 Год назад

    thx

  • @not_amanullah
    @not_amanullah 10 месяцев назад +1

    Understood++