what is the program output

This is a discussion on what is the program output within the C Programming forums, part of the General Programming Boards category; Code: #include <stdio.h> #include <stdlib.h> int main() { typedef union { struct { char c1,c2; } s; long j; float ...

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    8

    what is the program output

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
    typedef union
    {
    struct
    {
    char c1,c2;
    } s;
    long j;
    float x;
    } U;
    
    U example;
    example.s.c1 = 'a';
    example.s.c2 = 'b';
    example.j = 5;
    printf("%c %c %d", example.s.c1, example.s.c2, example.j);
    }
    why it is not printing a and b

  2. #2
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    Because it's union. not struct.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 05-29-2010, 05:24 AM
  2. calling an external program + capture output?
    By cyberfish in forum C++ Programming
    Replies: 4
    Last Post: 03-21-2008, 12:49 AM
  3. program looping with final output
    By hebali in forum C Programming
    Replies: 24
    Last Post: 02-28-2008, 09:58 AM
  4. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 10:17 PM
  5. Redirecting program output straight to an edit control
    By bennyandthejets in forum C++ Programming
    Replies: 5
    Last Post: 07-05-2004, 08:25 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21