answersLogoWhite

0

How can void pointer is assigned to an int type pointer?

Updated: 8/19/2019
User Avatar

Wiki User

13y ago

Best Answer

Example:

int *pi;

void *pv;

pv= (void *)pi;

pi= (int *)pv;

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How can void pointer is assigned to an int type pointer?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Application of void data type in c plus plus programming language?

The voiddata type is used when a function doesn't return any value, and/or when it has no parameters at all. Pointer type 'void *' is a generic pointer.A void pointer is used when it needs to be assigned to different data types later on in a program. Since it avoids type checking, void pointers should be used with care.


How do you Send arrays to function?

Simply by sending the base address from main() and catching that in a pointer in the pointer. void main() { int a[20]; sort(a); } void fun(int *p) { }


Is void a data type in c?

what is void data type Void is an empty data type normally used as a return type in C/C++, C#, Java functions/methods to declare that no value will be return by the function. The another use of void is to declare the pointer in C/C++ whe It is not sure that what data type will be addressed by the pointer. eg: void *p; Here p can hold the address of int or float or char or long int or double.


Why do you use a void pointer in a programme?

void is type of pointer that usually means that you can make it point to any data type. When you make a pointer point to somewhere its data type should match with the place where you want it to point. When you dont know the data type where it will point to then you can declare a void pointer and make it point to the data type it want.


Can a pointer to char data-type be type casted to pointer to integer type?

Yes it is possible in C language.includeint main(void) { char *cptr; int *iptr; iptr=(int*)cptr; return 0; }If you find the info useful Please Vote!!!


Different types of pointers in c language?

... are usable. void pointer (generic pointer) : a special type of pointer which point to some data of no specific types. void *p; null pointer : a special type of pointer which point nowhere. it is usually used to check if a pointer is pointing to a null or free the pointer during deallocation of memory in dynamic memory allocation; it is define by using the predefine constant NULL int *p=NULL; wild pointer : uninitialized pointer. it hold a garbage value. i.e it is not pointing to any memory location yet. dangling pointer: pointer pointing to a destroyed variable. it usually happen during dynamic memory allocation when the object is destroyed but not free and the pointer is still pointing to the destroy object.


A pointer to a function which receives nothing and returns nothing?

void (*funptr)(void); void fun (void); int main () { funptr = fun; funptr (); }


A c program to show the drawbeck of pointer?

int main (void) { int *p; /* uninitialized pointer */ *p = -1; /* writing to random memory */ return 0; }


Can you assigned value of int to a ordinary pointer?

Yes, with type-cast (but I don't see why you should): char *ptr = (char *)300;


In c How do you access variable declared in main in other function?

Only if you pass a pointer to it, eg: void sub (int *into) { *into= 3; } int main (void) { int myvariable; sub (&myvariable); return 0; }


C program pointers to pointers examples?

Pointer to Pointer is a double pointer, denoted by (**). Pointer stores the address of the variable and pointer to pointer stores the address of a pointer variable and syntax can be given as int **ptr2ptr;


What is the size of the pointer in c language?

Platform-dependent, printf ("%d\n", (int)sizeof (void *))will tell you.