Lab 5 - Start employee

Before you start this lab, make sure you have finished the coding for lab 4, which is due Sunday.

This lab is NOT submitted. We will extend this code in the next lab (after break), which will be submitted.

1. Define a struct for employees

The struct should include the following fields:

name, which should point to a string elsewhere
ssn, which should hold the 9 digits of a Social Security Number in an array in the struct
yearBorn as int
salary as int

Check that this code compiles, but it cannot run yet. Don't even bother linking (just use the gcc -c step)

2. Define a global variable

The variable should hold a single employee and initialize the values with a { } initialization.

3. Display function

Write a display function that takes a pointer to an employee struct and prints the info as follows:

On the first line, print the name, the ssn and the year born.
The ssn should be formatted as the standard xxx-xx-xxxx

On the second line, print the salary with a leading $ and a , after the thousands place, such as $25,000

Write main so that it will call display, passing the address of the global employee record.

To help with this, you will need to use the special printf modifiers we covered in class last week.

You can control how many characters you print from a string with a number . number between the % and the s. For example, %3.3s will print exactly 3 characters from the string, where the first 3 is the minimum number of characters to print and the second 3 is the maximum number of characters to print.

You can use a number like that with %d to force printing a certain width of digits. If you use a leading 0, if will 0 fill instead of blank fill. So %03d will print the number 4 as 004.