That darn "expected expression" error... a little help please!

This is a discussion on That darn "expected expression" error... a little help please! within the C Programming forums, part of the General Programming Boards category; Hey all, I'm a newbie to this forum and programming in general, but I can still usually figure out my ...

  1. #1
    Registered User
    Join Date
    Dec 2009
    Location
    Stuck in North Philly for the moment
    Posts
    2

    That darn "expected expression" error... a little help please!

    Hey all,
    I'm a newbie to this forum and programming in general, but I can still usually figure out my compiling errors. This one, however, has me stumped...

    The point of the program is to create a database of employee records using structs and arrays. Everything worked and compiled perfectly until I reached the part of program that calculates the number of employees close to retirement (in this case that means they have been employed for 15 years or more) and then displays their name.

    my error message was: lab9.c.61: error: expected expression before ,Ao= ,Ao token

    I was trying to use a for-loop to cycle through each struct, and if the value of "years" (years the person has been employed) is greater than or equal to 15 then the program would print their name and add +1 to the variable "total_retirement." I originally had a separate function for this, but got the same compiling error. I moved the code into the main body just in case the error had to do with passing structs to a separate function and all that, but still am getting the error so I guess that's not the case.

    The code is a little long, including everything just in case. Problem area is in bold, specific line is in italics.

    Code:
    #include <stdio.h>
    #include <string.h.
    
    Typedef struct
    {
    	char name[30];
    	char jobtitle[20];
    	double salary;
    	int years;
    } EMPLOYEE;
    
    void print_records (EMPLOYEE values[], int size);
    
    int main()
    {
    	int number_of_employees = 0;
    	double sum;
    	double average_salary;
    
    	printf(“Welcome! How many employee recores will you be storing? \n”);
    	scanf(“%d”, &number_of_employees];
    
    EMPLOYEE employees[number_of_employees];
    
    int x;
    for (x = 0; x < number_of_employees; x++)
    {
    	printf(“Enter the last name for employee (%d): \n”, x + 1);
    	scanf(“%s”, employees[x].name);
    
    	prinf(“Enter job title: \n”);
    	scanf(“%s”, employees[x].jobtitle);
    
    	prinf(“Enter salary: \n”);
    	scanf(“%lf”, employees[x].salary);
    
    	prinf(“Enter years employed: \n”);
    	scanf(“%s”, employees[x].years);
    }
    
    printf(“Thank you. Here is a listing of all your employees: \n\n”);
    print_records(employees, number_of_employees);
    
    for (x = 0; x < number_of employees; x++)
    {
    	sum = sum + employees[x].salary;
    }
    
    printf(“The total salary expense is %.2lf \n”, sum);
    
    average_salary = (sum / number_of_employees);
    printf(“The average salary is %.2lf \n”, average_salary);
    
    
    int total_retirement = 0; 
    int y;
    for (y = 0; y < number_of_employees; y++)
    {
    	if (employees[y].years>==15)
    		{
    			printf(“%s\n”, employees[y].name);
    			total_retirement++;
    		}
    	else
    		{
    			total_retirement = total_retirement;
    		}
    }
    printf(“Total number of employees close to retirement: %d \n”, total_retirement);
    
    }
    
    void print_records(EMPLOYEE values[], int size)
    {
    	int x;
    	for (x = 0; x < size; x++)
    	{
    		printf(“----------- \n”);
    		printf(“Name: %s\n”, values[x].name);
    		printf(“Job title: %s\n”, values[x].jobtitle);
    		printf(“Salary: %.2lf \n”, values[x].salary);
    		printf(“Years employed: %d \n”, values[x].years);
    	}
    }
    thanks!

  2. #2
    Registered User
    Join Date
    Mar 2009
    Posts
    399
    Code:
    #include <string.h.
    > = =
    Code:
    f (employees[y].years>==15)

  3. #3
    Registered User
    Join Date
    Dec 2009
    Location
    Stuck in North Philly for the moment
    Posts
    2
    Oops, my bad...
    " #include <string.h. " was a typo on my part when reposting the code. The original does not include that typo and appears as " #include <string.h> ". Any other suggestions?

  4. #4
    Registered User
    Join Date
    Aug 2006
    Posts
    99
    See the post above last. >== is not an operator.

Popular pages Recent additions subscribe to a feed

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