Похожие чаты

Why do we type cast malloc into int*? the instructor

said malloc returns a void* pointer. can someone explain the difference. how can a memory location be void type?

8 ответов

23 просмотра

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

skalpasi- Автор вопроса
Prince Of Persia [field = CE,DM = BLOCK]
void* isn't a pointer of void variables Because vo...

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?

skalpasi- Автор вопроса
The prodigal ᥀
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

skalpasi
in functions, it's a type which doesn't return an...

Ok then, void* is a special thing then.. isn't it?

skalpasi
but i don't understand why we cast pointers to the...

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.

skalpasi
but i don't understand why we cast pointers to the...

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

skalpasi
but i don't understand why we cast pointers to the...

As i remember, array is Pointer. You dont have to take its addr (&).

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта