C Programming - Pointers - Discussion
Discussion Forum : Pointers - Find Output of Program (Q.No. 13)
13.
What will be the output of the program?
#include<stdio.h>
int main()
{
int arr[3] = {2, 3, 4};
char *p;
p = arr;
p = (char*)((int*)(p));
printf("%d, ", *p);
p = (int*)(p+1);
printf("%d", *p);
return 0;
}
Discussion:
87 comments Page 7 of 9.
Pankaj kumar said:
8 years ago
p = (char*)((int*)(p)); can anyone explain this?
(1)
Komal said:
9 years ago
Very good and clear explanation. Thank you all.
Raghav said:
1 decade ago
(char*)((int*)(p))
Could someone explain this?
Could someone explain this?
DISH said:
9 years ago
Do we need to typecast the pointer every time?
Shashank said:
1 decade ago
Please tell me how this program will execute.
Vanni said:
1 decade ago
I didn't get this one can anyone explain me?
Akhil said:
1 decade ago
Thank you for such a nice discussion... :)
Vaibhav said:
1 decade ago
p = (int*)(p+1) ; what it does actually ?
Puru said:
1 decade ago
@viraj accepted your idea. its the same
Purushotham said:
1 decade ago
p = arr;
causes compile time error
causes compile time error
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers