Hi everyone,
This is really my first time posting and I'm a newcomer to programming. I'm wondering if someone can point out what i am doing wrong in the if and for loop with choice 2.
Code:
#include <stdio.h>
#include <stdlib.h>
struct employeedatabase
{
char firstname[ 20 ];
char lastname[ 20 ];
char dateofbirth[ 10 ];
char ssn[ 11 ];
char contactnumber[ 13 ];
unsignedint age[ 2 ];
char gender[ 6 ];
double hourlysalary[ 10 ];
}employees[10];
//Function prototype
int choice = 0;
int quit = 3;
int counter = 0;
int i = 0;
int main( )
{
printf("\n********** MENU **********\n\n"
"Enter your choice:\n"
"1: Add a New Employee to the list.\n"
"2: Print Current Employees.\n"
"3: Quit.\n\n" );
printf("Your choice is: ");
scanf( "%d", &choice);
while(choice !=3)
{
if( choice == 1)
{
printf("\n***** New Employee *****\n");
printf("\nPlease fill in all information below:\n\n");
printf("First Name: ");
scanf("%s", employees[counter].firstname); //input for First Name
printf("Last Name: ");
scanf("%s", employees[counter].lastname); //input for Last Name
printf("DOB (MM/DD/YYYY): ");
scanf("%s", employees[counter].dateofbirth); //Input for DOB
printf("SSN: ");
scanf("%s", employees[counter].ssn); //Input for Social
printf("Telephone Number: ");
scanf("%s", employees[counter].contactnumber); //Input for Phone Number
printf("Gender: ");
scanf("%s", employees[counter].gender); //Input for Gender
printf("Hourly Salary: $");
scanf("%lf", employees[counter].hourlysalary); //Input for Salary
printf("\nEnter your choice:\n"
"1: Add a New Employee to the list.\n"
"2: Print Current Employees.\n"
"3: Quit.\n\n" );
printf("Your choice is: ");
scanf( "%d", &choice);
if( choice == 1) counter++;// Increments employees by one
}//End of Choice 1
if(choice == 2)
{
printf("\n***** List of Employees *****\n");
{
for(i = 0;i <= 10; i++)
{
printf(employees[counter].firstname);
printf(employees[counter].lastname);
printf(employees[counter].dateofbirth);
printf(employees[counter].ssn);
printf(employees[counter].contactnumber);
printf(employees[counter].gender);
printf(employees[counter].hourlysalary);
}//End of for loop
}
}//End of Choice 2
}// End of While Loop
}// End main