Developer community
0 votes
asked by Expert (11.4k points) 15 23 32 | 35 views

1 Answer

0 votes
A void pointer is a C convention for a raw address. The compiler has no idea what type of object a void Pointer really points to. If you write
int *ip;
ip points to an int. If you write
void *p;
p doesn’t point to a void!
In C and C++, any time you need a void pointer, you can use anotherpointer type. For example, if you have a char*, you can pass it to afunction that expects a void*. You don’t even need to cast it. In C (butnot in C++), you can use a void* any time you need any kind of pointer, without casting. (In C++, you need to cast it).
A void pointer is used for working with raw memory or for passing a pointer to an unspecified type.
Some C code operates on raw memory. When C was first invented, character pointers (char *) were used for that. Then people startedgetting confused about when a character pointer was a string, when it was a character array, and when it was raw memory.
answered by Guru (24.6k points) 30 56 86

Related questions

0 votes
2 answers
asked by allison Sr Member (1.5k points) 11 27 41 | 213 views
0 votes
1 answer
asked by carlton Sr Member (4k points) 5 11 21 | 64 views
0 votes
1 answer
asked by smith Geek (15.3k points) 18 43 68 | 18 views
0 votes
1 answer
asked by sara Guru (24.6k points) 30 56 86 | 36 views
0 votes
1 answer
asked by rock Expert (15k points) 15 23 31 | 38 views
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true


C Books Guide and List
C++ Books Guide and List
Best Java Books

3.8k questions

4k answers


10.7k users

3,754 questions
4,046 answers
10,709 users