Pointer and there increment variable | pointer increment | pointer And Array

How to increase the pointer value in c
Void *ptr;
myStruct myArray[10];
ptr=myArray;
Which of the following is the correct way to increment the variable “Ptr”?
a)ptr=ptr+sizeof(myStruct);
b)++(int*)ptr;
c)ptr=ptr+sizeof(myArray);
d)increment*ptr;

Debugging Answer:
Ans is
b) ++(int*)ptr;

Debuging solution:
Because it is the proper way to increase the pointer variable
int it indicate pointer is the integer data type.

Post a Comment

0 Comments