Errors with structures...

This is a discussion on Errors with structures... within the C Programming forums, part of the General Programming Boards category; Hi, This program for some reason generates errors..........why? But when i used a variable as a 'middle-person' to assign the ...

  1. #1
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020

    Errors with structures...

    Hi, This program for some reason generates errors..........why? But when i used a variable as a 'middle-person' to assign the input to it first then assighn the input to the structure member and printing it it's ok. Why ?

    thnx

    Code:
    #include <stdio.h>
    
    struct integer {
       char c;
       short s;
       int i;
       long b;
    };
    
    int main()
    {
       struct integer number;
    
       scanf( "%d", number.i );
       printf( "%d", number.i );
    
       system("PAUSE");
       return 0;
    }

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    scanf() takes the address of the variable -

    scanf( "%d", &number.i );

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Structures within structures for a database
    By Holtzy in forum C Programming
    Replies: 2
    Last Post: 04-30-2008, 07:06 AM
  2. global namespace errors
    By stubaan in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2008, 03:11 PM
  3. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  4. Header File Errors...
    By Junior89 in forum C++ Programming
    Replies: 5
    Last Post: 07-08-2007, 12:28 AM
  5. executing errors
    By s0ul2squeeze in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2002, 12:43 PM

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