C Programming - Strings - Discussion
Discussion Forum : Strings - Find Output of Program (Q.No. 17)
17.
If the size of pointer is 32 bits What will be the output of the program ?
#include<stdio.h>
int main()
{
char a[] = "Visual C++";
char *b = "Visual C++";
printf("%d, %d\n", sizeof(a), sizeof(b));
printf("%d, %d", sizeof(*a), sizeof(*b));
return 0;
}
Discussion:
31 comments Page 4 of 4.
Gouri Suders said:
1 week ago
Here, char *b is a pointer variable, so the number of bytes depends on the bitness of the system.
So if the system is 32, then the answer is 4.
If it is 64 bit system, then it is 8.
So, that's why here 4 bit, here they considered a 32-bit system.
So if the system is 32, then the answer is 4.
If it is 64 bit system, then it is 8.
So, that's why here 4 bit, here they considered a 32-bit system.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers