+ 2

What is the output and how?

#include <stdio.h> union Values{ int first; int second; char third[1]; }; int main() { union Values v; v.first=0; v.third[0]='b'; printf("%d",v.second); return 0; }

9th Jul 2022, 12:58 PM
Rohit Ahuja
Rohit Ahuja - avatar
2 Antworten
+ 4
A union is a special data type available in C that allows to store different data types in the same memory location. You can define a union with many members, but only one member can contain a value at any given time -> store b -> ascii of b is 98 -> so i think o/p is 98...
9th Jul 2022, 1:38 PM
Mihir Lalwani
Mihir Lalwani - avatar
+ 1
Thanks bro 👍
10th Jul 2022, 9:06 AM
Rohit Ahuja
Rohit Ahuja - avatar