Thread: Recalling code meaning

  1. #1
    Registered User
    Join Date
    Mar 2006
    Location
    Tenth Planet
    Posts
    1

    Recalling code meaning

    I'm going through my old C programming notes trying to recall back my c programming knowledge that I learn about 2 years ago and I'm trying to re-understand what this code meant. It should be a piece of cake for you guys.

    Code:
    int emp_id;
    float salary
    struct employeeData employee;
    
    printf("Enter  Employee ID to update (0001 - 1000): ");
    scanf("%d%, &emp_id);
    I'm trying to understand this,
    struct employeeData employee;

    what is the purpose of writing employee at the back of the line?

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    <type> <variable>
    Code:
    int emp_id;
    float salary; /* missign semicolon */
    struct employeeData employee;
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    Code:
    scanf("%d%, &emp_id);
    should be
    Code:
    scanf("%d", &emp_id);
    struct employeeData employee;

    the above code means that u are declaring a variable employee of type struct employeedata. where a struct employeedata might contain many other attributes like ID, name, salary and so on


    ssharish2005

  4. #4
    Madly in anger with you
    Join Date
    Nov 2005
    Posts
    211
    Code:
    struct employeeData employee;
    declares an instance of employeeData named employee. thus meaning, after that declaration you can use employee to initialize/set the members of the employeeData struct.
    Last edited by Bleech; 03-25-2006 at 07:38 PM.

    Intel Core 2 Quad Q6600 @ 2.40 GHz
    3072 MB PC2-5300 DDR2
    2 x 320 GB SATA (640 GB)
    NVIDIA GeForce 8400GS 256 MB PCI-E

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Proposal: Code colouring
    By Perspective in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 05-14-2007, 07:23 AM
  2. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 10:20 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  4. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM