:: Re: [DNG] simple-netaid from scratc…
Etusivu
Poista viesti
Vastaa
Lähettäjä: Didier Kryn
Päiväys:  
Vastaanottaja: dng
Aihe: Re: [DNG] simple-netaid from scratch
Le 10/06/2019 à 20:20, s@po a écrit :
> One harmfull situation is when you pass an array[n] to a function has an argument, for example..
> Usign 'sizeof' inside, will return the size of the pointer and not the size of elements on the array..


    It is a "beginner's" error to confuse the size of the pointer with
the size of the pointed. Indeed there are many "beginner's" errors
possible in C. But it's not the same story.

    I admit that I have often used sizeof(array)/sizeof(element) to
mean the number of elements. But when I realized - recently - that it
was an artefact relying on the compiler and not on the language, and not
semantically true, I stopped. I would now prefer using a macro as you
suggested, or a constant.

    Didier