Thread: unions

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    10

    unions

    How do I read in from the keyboard when using unions.?

    my code:

    printf("Type a character: \n");
    scanf("%c", number.c);

    I am getting this error:

    /tmp/cc6fjFyR.o(.text+0x5f): In function `main':
    : undefined reference to `scan'
    collect2: ld returned 1 exit status

    I tried it with and w/o address operand. My book doesn't seem to mention how to do this. Any suggestions? Thanks

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >scanf("%c", number.c);
    First this should be:
    scanf("%c", &number.c);

    Second the error message you pasted references scan, not scanf.

  3. #3
    Registered User
    Join Date
    Sep 2005
    Posts
    10

    all set

    Ok, I figured it out. It was down the line I forgot the 'f' in one of my scanf statements. I looked at it 20 times and never caught it until now. Thanks for replying and sorry for wasting your time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unions of the same size and pointers
    By holychicken in forum C Programming
    Replies: 9
    Last Post: 10-06-2008, 03:29 PM
  2. Structures, Unions and Classes
    By Makoy in forum C++ Programming
    Replies: 2
    Last Post: 02-23-2004, 02:57 PM
  3. Structures - Unions
    By AProg in forum C Programming
    Replies: 16
    Last Post: 05-27-2003, 12:43 AM
  4. unions problems!
    By nextus in forum C++ Programming
    Replies: 3
    Last Post: 01-12-2003, 04:04 AM
  5. Unions in c++
    By The Gweech in forum C++ Programming
    Replies: 5
    Last Post: 08-06-2002, 08:14 AM