1,913 views
3 3 votes
#include<stdio.h>
int main()
{
    int a = 10;
    void *ptr = &a;
    printf("%d", sizeof(ptr));
    return 0;
}
output =8

how ?if we know size of pointer is already machine dependent then in this case ptr is referring a address of int  then how output 8 ?

Please log in or register to answer this question.

Position:
Show:

Related questions

7 7 votes
2 2 answers
370
370 views
GO Classes asked Jun 29
370 views
What is the output of the following code?#include <stdio.h struct Item { int code; int price; }; void update(struct Item *p) { p->price = p->price + 20; (*p).code = (*p)....
6 6 votes
2 2 answers
340
340 views
GO Classes asked Jun 29
340 views
What is the output of the following code?#include <stdio.h struct Box { int width; int height; }; int main() { struct Box b = {4, 6}; struct Box *p = &b; p->width = p->wi...
6 6 votes
2 2 answers
360
360 views
GO Classes asked Jun 27
360 views
What will happen in the following code?#include <stdio.h #include <stdlib.h int main() { int *p = (int *)malloc(sizeof(int)); *p = 10; free(p); printf("%d", *p); return 0...
8 8 votes
2 2 answers
299
299 views
GO Classes asked Jun 27
299 views
What is the output of the following code?#include <stdio.h int main() { int x = 25; void *p = &x; printf("%d", *(int *)p); return 0; }$\texttt{25}$ Address of $\texttt{x}...