LevyDee is right IF the array had been sent to another function. In the function it was declared in, it will have size 10.
Tubby, the union has ONLY a size big enough for the largest member. THE largest member, not the SUM of all the members. That would be true for a struct, though. (along with some padding which would depend on your compiler, as LevyDee mentioned).
adak and levy dee, thanks a lot. ok union takes the size of the biggest member .. Will remember that ..
i have 1 more doubt. How does this give 3, shouldnt it give 3*sizeof(int) cuz its an integer array.
It's just the digit '1', and then the digit '2', and then the digit '3'.
This statement is either confused or misleading. The lack of single quotes means those initializers are not character literals, but the low end of character set typically doesn't include printable characters, so it's harder to say what the actual values are. Using ASCII as a base, we can say that 1, 2, and 3 are the control characters SOH, STX, and ETX, respectively. But they're most certainly not equivalent to the characters '1', '2', and '3', which (still assuming ASCII) have the values of 49, 50, and 51.
Without quote marks in there, it may not compile, as is.
Using a string literal to initialize an array of char is the exception (one provided for convenience), not the rule. The rule is using an initialization list as in tubby's code. So it's required to compile (assuming the rest of the code is equally correct).