Memory manipulation functions in C

Sdílet
Vložit
  • čas přidán 9. 09. 2024

Komentáře • 60

  • @starfart69
    @starfart69 Před 3 lety +11

    This is a hidden gem I hope everyone sees. Reading the documentation can be frustrating for beginners.

  • @fun-damentals6354
    @fun-damentals6354 Před 11 měsíci +3

    possibly the best channel on yt for c. extremely simple and clear explanation, nice accent and good approach to teaching

  • @federicobau8651
    @federicobau8651 Před 3 lety +8

    Just start to learn C and I found your channel, i just subcribed and I don't regret it.

  • @profittaker6662
    @profittaker6662 Před 4 lety +4

    Excellent series of over a hundred short videos (116) about basic computer functions and basic programming. These are the things every programmer should know master master first.

  • @pushkarnath1904
    @pushkarnath1904 Před 3 lety +1

    In youtube lots of channels are there but No one has ever say even one word about this topic
    Thanks dude I was searching for this 🤟🤟

  • @codinggirl_
    @codinggirl_ Před 4 lety +7

    Thank you so much for such a clear explanation!!! Now I finally got the usage of these functions!

  • @MrAnandml
    @MrAnandml Před 2 lety

    This is some great channel for C language

  • @habibhasanshakil9086
    @habibhasanshakil9086 Před 2 lety +1

    I have finished almost the full playlist "Unix process in c". I think some of the videos on this playlist are not in order. Anyway, your videos are helping me a lot.

    • @CodeVault
      @CodeVault  Před 2 lety

      Oh! Please do tell me which ones are not in order. I know CZcams sometimes messes up the order in there

  • @zltn_brkl
    @zltn_brkl Před 3 lety +2

    Man you deserve even more subscribers and views, the effort you put into your videos is huge, thanks a lot. Also would have a question to you, I have some experience in C, and I really want to go through your tutorials, but I could not figure out what the real order of the videos are, could you help me out? Thank you best regards.

    • @CodeVault
      @CodeVault  Před 3 lety +4

      Thank you! Most videos don't have an orde aside from the linked list, processes and threads courses (which have their own playlist). They are meant as completely standalone videos so people can quickly understand a topic they are stuck on without having to go through hours of courses. But you're right, if you want to learn C from these videos it can be quite confusing... I will look into putting all videos in playlists basic on their topic, is that alright?

    • @zltn_brkl
      @zltn_brkl Před 3 lety

      @@CodeVault I appreciate your help. Thank you very much.

  • @koraybulut3175
    @koraybulut3175 Před 3 lety +1

    Thank you so much!
    Excellent series of videos with clear explanations!
    But, the playlist is not organised.
    Please, short them.
    It would be much more clear.
    Thanks a lot man!

    • @CodeVault
      @CodeVault  Před 3 lety +2

      Yeah, sorry about that, that playlist is just a collection of ALL the C videos on the channel (in chronological order). I will create some playlist based on their topic, but the order is still not going to matter as most of them are meant to be standalone.

  • @carlosfernandez6470
    @carlosfernandez6470 Před rokem

    Sorry i keep watching and you explained 👍💪

  • @mukteshgautam4050
    @mukteshgautam4050 Před 5 lety +3

    informative video, thanks sir! one question you said 1 is four bytes in int which is 0001its four bit right so that means every number has its own four bit i did not quite understand! it is stored in hexadecimal format in the program?

    • @CodeVault
      @CodeVault  Před 5 lety +4

      "so that means every number has its own four bit"
      Now here's where your misunderstanding begins.
      A number, whether it be in the real world, in programming or in a video game doesn't HAVE bytes.
      BUT, a variable, the place where we can store numbers in a computer, does have BYTES.
      An INT usually has 4 bytes and a SHORT INT has 2 bytes.
      ---------------
      When I said that the 1 inside an INT is 0 0 0 1, each digit represented a BYTE.
      In hexadecimal it would be: 00 00 00 01
      In binary (the way it is stored in memory) would actually be: 00000000 00000000 00000000 00000001
      A 1 inside a SHORT INT i wrote it as 0 1, again, one digit per BYTE.
      In hexadecimal it would be: 00 01
      And in binary: 00000000 00000001
      Notice the difference?
      "it is stored in hexadecimal format in the program?"
      No, it always goes down to bits.
      So that was just a simplified notation on my part.

    • @mukteshgautam4050
      @mukteshgautam4050 Před 5 lety +1

      @@CodeVault Thank you so much for explaining it so precisely!
      You have cleared all my doubts!
      : )

    • @sarvottampriyadarshee5425
      @sarvottampriyadarshee5425 Před 4 lety +1

      @@CodeVault also had the same doubt, very much cleared by you!

    • @sepgh2216
      @sepgh2216 Před 8 měsíci

      ​@@CodeVault This is a part I struggled with as well. What I still can't understand is if it always goes down to bits, why didn't metset(arr1, 1,...) produce all bits as 1?
      Rewatched the video, if I am not wrong, thats due to memset accepting bytes in second parameter and not bits, or better say whatever goes in second parameter is treated as a byte and not bit.

  • @muhammadsafiullah8428
    @muhammadsafiullah8428 Před 5 lety +2

    Appreciate you, man.

  • @sarvottampriyadarshee5425

    man you explained it so damn sharp!
    Thank you so much!

  • @laenprogrammation
    @laenprogrammation Před rokem +2

    Small mistake : as c is little endian, the int 1 is actually : 1 0 0 0

    • @CodeVault
      @CodeVault  Před rokem +1

      That's correct. Good observation, it was a mistake on my part

  • @carlosfernandez6470
    @carlosfernandez6470 Před rokem

    Why memset only works with 0(zero)?

  • @ahmednabil465
    @ahmednabil465 Před rokem

    you are the best man !

  • @ForeverNils
    @ForeverNils Před 2 lety

    Thank you for your work

  • @04.nehalsingh12
    @04.nehalsingh12 Před 2 lety

    awesome tutorial sir

  • @ailijic
    @ailijic Před 3 lety +1

    Be careful when comparing structs. Do the compare element by element in case the padding is different.

    • @CodeVault
      @CodeVault  Před 3 lety +2

      Thanks but padding and alignment won't be different on the same system

  • @turuus5215
    @turuus5215 Před 2 lety

    Originally in the 1st int, we have a decimal expression of 0003, don't we?
    I'm a little confused by how it was turned into the hexadecimal expression of 01010101.
    Conversion looks like these: 0 01, 001, 001, 301. Why?

    • @CodeVault
      @CodeVault  Před 2 lety

      That's because of how memset works. So, let's take a look at arr1[0].
      First we have the element 3, which is in hexadecimal: 00 00 00 03 (each pair for 2 hex digits represent a single byte)
      Now, after we call memset(arr1[0], 1, 2 * sizeof(int));
      memset will change each BYTE to have the value 1, so since arr1[0] is an int that has 4 bytes we will get this value in arr1[0]:
      01 01 01 01 (in hexadecimal)
      In binary this would look like so:
      00000001 00000001 00000001 00000001
      Hope that's more clear now

  • @ezraakran7158
    @ezraakran7158 Před 3 lety

    Great explanation mate

  • @ragnarlothbrok367
    @ragnarlothbrok367 Před 2 lety

    bro u golden

  • @kamilziemian995
    @kamilziemian995 Před 2 lety

    I just discover your channel and want to watch all your videos on C. My skills in C declined in last years. Is there any order in which you should watch "The C programming language made simple"? I have on first position "Memory manipulation functions in C", definitely not "Hello World!" program. The latter being the most important program in the world!

    • @CodeVault
      @CodeVault  Před 2 lety

      The videos in that playlist were never made to be watched in any specific order. I did create some more specific playlists in which I added all the relevant videos and I put them in order from least complex to most complex (although, again, they are not perfect)
      Here you can check them out: czcams.com/users/CodeVaultplaylists
      The Linked Lists, Unix Processes and Unix Threads playlists are actually made to be watched in order

  • @MetroidVibes
    @MetroidVibes Před 2 lety +1

    Hello ! Thank you for this great video. Would it be possible to have more explanation about the memset function ?
    I understood that we get "16843009" for each number when we print the result of memset as an int (with %d) because the hexadecimal result is "01010101". But as you said "memset will set every single byte to 1", I would expect the result of memset to be something like "00000001". There is probably something I don't understand about memory. I am reading about it, but I am still confused.

    • @CodeVault
      @CodeVault  Před 2 lety +4

      Well, an int has 4 bytes. Since memset sets every byte to 1 (in the example in the video) we get:
      01010101
      Note that this notation is in hexadecimal and each 2 characters represent a single byte. If we were to write it in binary you would get this:
      00000001000000010000000100000001

    • @MetroidVibes
      @MetroidVibes Před 2 lety

      @@CodeVault it makes more sense now 😅 since I am new to this it’s still tricky sometimes !
      I’ll read about the use of %x, but can you tell me if it is possible to use printf to print actual binary format ?
      Thank you a lot ! :)

    • @CodeVault
      @CodeVault  Před 2 lety +1

      There's a video on it: code-vault.net/lesson/0iqp12va9m:1603820088926

    • @MetroidVibes
      @MetroidVibes Před 2 lety

      @@CodeVault oh cool ! Thank you ! I finally made my own function to do that. But I’ll have a look at your video 👍🏼

  • @amanpatel6203
    @amanpatel6203 Před 3 lety

    wow woderfull explanation

  • @lg1360to
    @lg1360to Před 2 lety

    can you suggest me c documentation?... I'm not able to find it.

    • @CodeVault
      @CodeVault  Před 2 lety

      The most reliable documentation that I use seems to be this site: www.cplusplus.com/reference/cstring/memset/

  • @kotesh3777
    @kotesh3777 Před rokem

    Hi is there any planning C++ concepts

    • @CodeVault
      @CodeVault  Před rokem

      Yes, OOP and memory management in C++ are some of the topics I will look into

  • @adeled8833
    @adeled8833 Před 4 lety

    What if in memchr ima try to find the byte with a value of > 256

    • @CodeVault
      @CodeVault  Před 4 lety

      Since a byte can only go up to the value 255, you can't. You'll need to probably just make a for loop and check that manually.

    • @adeled8833
      @adeled8833 Před 4 lety

      CodeVault okay thank you :)))

  • @bakerstreet7833
    @bakerstreet7833 Před 4 lety

    good about memset!

  • @codewithovi997
    @codewithovi997 Před 4 lety

    Your videos are great but the playlist is not organised ... like i don’t understand which one is the first one in your playlist.

    • @CodeVault
      @CodeVault  Před 4 lety +1

      You mean the C playlist? That one is just all the videos related to C on the order they were uploaded... They weren't made in a specific order and aren't supposed to have a continuity.

    • @kkrolley
      @kkrolley Před 3 lety

      @@CodeVault Please if you do find some time, do a C course you are very clear in your explanations!

  • @arvindersingh9863
    @arvindersingh9863 Před 4 lety

    👍👍👍

  • @ailijic
    @ailijic Před 3 lety +1

    The method for comparing array of int and array of short only works on little endian systems, be careful.

  • @justmell0o
    @justmell0o Před 10 měsíci

    ti indus?

  • @bcsamrudh
    @bcsamrudh Před 5 měsíci

    6:31 6:32 6:33