Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have been getting these error messages while trying to compile my c file.

projecttwo.c:4:5: error: expected identifier or ‘(’ before ‘continue’
 int continue= y;
     ^
projecttwo.c:5:7: error: expected expression before ‘continue’
 while(continue==y)
       ^
projecttwo.c:31:14: error: expected expression before ‘continue’
 scanf( "%s", continue );


Here is the full code.

C
#include <stdio.h>
int main()
{
int continue= y;
while(continue==y)
{
    unsigned char fullName[50];
     int employeeHoursworked, employeePayrate, totalcheckamount;
     printf( "First, please enter your full name.\n" );
      scanf( "%s", &fullName );
     printf( "Second, please enter your pay rate.\n" );
      scanf( "%d", &employeePayrate );
     printf( "Finally, please enter the amount of hours worked.\n" );
      scanf( "%d", &employeeHoursworked );
if (employeeHoursworked>40)
{
 totalcheckamount = ((40*employeePayrate)+ ((employeeHoursworked-40)*employeePayrate*2));
}
else
{
   totalcheckamount = (employeeHoursworked*employeePayrate);
}
  printf( "Name: &fullName\n Total Check Amount: &totalcheckamount.\n" );
{
FILE *employeeFile;
employeeFile = fopen( "&fullName.txt", "w+" );
fputs( "Name: &fullName\n Total Check Amount: &totalcheckamount", employeeFile );
fclose( employeeFile);
}
printf( "Would you like to continue? [y/n]\n" );
scanf( "%s", continue );
}
}


What I have tried:

I have tried to delete some code and moving some. Please help. Thank you.
Posted
Updated 6-Apr-18 11:56am
v2

In the C and C++ languages, continue is a reserved word so you can not use it to name a variable. Call it carry_on or something like that and you will be OK.

Also - it can be helpful to comprehend code if is indented appropriately.
 
Share this answer
 
Comments
CPallini 6-Apr-18 17:57pm    
5.
This probably have somethingwith the fact that 'continue' is a statement of C.
'continue' is a reserved word and can't be a variable.
continue statement in C[^]
 
Share this answer
 
v2
Comments
CPallini 6-Apr-18 17:57pm    
5.
Patrice T 6-Apr-18 18:04pm    
Thank you
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900