void* isn't a pointer of void variables Because void variable does not exist (you cannot have an variable of void - "void name;") void* is a pointer to anything It could be int or int[] or char[] or int[][] or anything So for using that variable which void* is pointing to, you have to cast void* to something else
but i don't understand why we cast pointers to the data type of the variable it is pointing to. for ex- char msg[10] = "hello"; char *ptr = &msg; why do we use char data type for pointer when *ptr will always store an integral memory address. memory address are in hex/int format right? i might sound annoying but I'm studying this pointer concept for first time and is very confusing :(
What's a void type according to you?
in functions, it's a type which doesn't return anything but i don't think there is something called void data type
Ok then, void* is a special thing then.. isn't it?
there's mostly two reasons: 1. to maintain some form of type safety 2. alignment info for the type so you can do simple pointer arithmetic.
it's fine. Your questions aren't annoying, it's just whoever taugh you pointers probably didn't do a good job at it when
As i remember, array is Pointer. You dont have to take its addr (&).
Обсуждают сегодня