first of all I'm not a native english speaker so sorry in case of misspelling.
In my current practice I have the habit to use cast to work directly with the memory. But I heard that some peoples are considering that like a bad practice.
this is an example on the way I use casting:
1 2 3 4 5 6 7 8 9 10 11 12 13 | void *ft_memchr(const void *ptr, int value, int num) { int i; i = 0; while (i < num) { if (*((char *)ptr + i) == value) return ((void *)((char *)ptr + i)); i++; } return (0); } |
Like I said my primary goal is to work with memory in the way I want to. So using cast let me for example doing pointer arithmetic.
I don't understand why we need to be aware of casting when it can be really useful.
Thank you :)