Gezinmeyi atla
You cannot add to a void pointer in C. The compiler does not know the size.
0:00 / 1:37

You cannot add to a void pointer in C. The compiler does not know the size.

tetsuo

@tetsuoai241 B takipçi

X profili
612 beğeniİndirOrijinal gönderi

28.004 görüntüleme

You cannot add to a void pointer in C. The compiler does not know the size. The everyday fix is to cast it to char* so the math is in bytes, then multiply by the element size yourself. Stanford CS107, lecture 4

15 Yorum

Yorumlar X (Twitter) üzerindeki orijinal gönderiden alınmıştır

  • acidburn profil fotoğrafı

    @signerless

    this is what matters

    5 beğeni

  • Jack profil fotoğrafı

    @jackisgeeky

    You shouldn’t be using void pointers in the first place.

    3 beğeni

  • Ray Epps profil fotoğrafı

    @rayeppsonx

    there was a time when i was addicted to the stanford and harvard cs class recordings

    2 beğeni

  • JETLAB-X profil fotoğrafı

    @JETLABX

    Good Lord… flashback nightmares… I despised Object C/C++ glad XCode lets me do stuff with Swift.

    2 beğeni

  • BullBear.News profil fotoğrafı

    @bullbear_info

    Nothing like realizing at 2 AM that your pointer arithmetic on a void star just silently broke on ARM because the ABI handles things differently.

    2 beğeni

  • Adrien Chauvet profil fotoğrafı

    @adrien_chauvet

    Thank God, with AI it's becoming increasingly possible to create software without having to struggle with such hieroglyphs.

    1 beğeni

  • symbols profil fotoğrafı

    @japaneseremedy

    I am self taught and felt like an imposter for all the 15years until I watched this lecture, then I saw my true mind.

    1 beğeni

  • Chris Ziomkowski profil fotoğrafı

    @ZiomkowskiChris

    I worked on a custom architecture that didn't have byte addressing, so char* was the same as int*. Assuming char* is only 1 byte wide is a very bad idea. You should cast void* to uint64_t and do your work as integers if you want it to be portable.

    1 beğeni

  • Deepak profil fotoğrafı

    @HaXX0R

    hmm interesting.

  • Gustavo Rocambóli profil fotoğrafı

    @Floripa2006

    2026 bro no one cares anymore

  • 音GATO profil fotoğrafı

    @realRiverC

    void pointers, the real polymorphism

  • ᴅ ᴇ ᴀ ᴅ ʙ ᴏ ʏ profil fotoğrafı

    @DeadboyEzra

    Boy, you don’t want my ass multiplying.

  • Mēgan DeMarco profil fotoğrafı

    @Musk_Megan2026

    No comprehend lol I actually don't know what you mean by this one explain please

  • Pitchfork & Torch ♞ profil fotoğrafı

    @SuddenlyJon

    void* can’t count. We measure in chars!

  • Clank profil fotoğrafı

    @clankenluben

    Wow even more basic shit information will it ever stop thank you