Unknown Error - Solution?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vina
    New Member
    • Nov 2011
    • 1

    Unknown Error - Solution?

    Code:
    #include <stdio.h>
    float calculateCharges(float hours);
    
    main( )
    
    {	int i=0;
    
    	printf("Enter in the number of cars");
    	scanf("%d", &i);
    
    	const int  NUMBER_OF_CARS=i;
    	float hours[NUMBER_OF_CARS];
    	float charges[NUMBER_OF_CARS];
    	float totalCharges=0.0;
    	float totalHours=0.0;
    
    	
    	printf("Car\tHours\tCharges");
    
    	for(i=0; i<NUMBER_OF_CARS; i++)
    	
    	{	
    		printf("Enter hours %d:", i);
    		scanf("%f", hours[i]);
    		
    	}
     	
    	int a=0;
    
    	for(a=0; a<NUMBER_OF_CARS; a++)
    	{
    		charges[a]= calculateCharges(hours[a]);
     		int count=a+1;
    		printf("\n%d\t%.2f\t%.2f", count, hours[a], charges[a]);
    
    		totalCharges = totalCharges + charges[a];
    		totalHours= totalHours + hours[a];
    	}
    	
    	printf("\nTOTAL\t%.2f\t%.2f", totalHours, totalCharges);
    
    }
    
    float calculateCharges (float hours)
    	{
    	if(hours>0 && hours<=3)
    		{return 2.00;}
    	if(hours>3 && hours<16)
    		{return 2.00+(hours-3)*0.50;}
    	if(hours>=16)
    		{return 10.00;}
    	}

    I keep receiving the error

    {In file included from /opt/gnu/lib/gcc-lib/sparc-sunh:solaris2.8/3.3/include/stdio.h:14,
    ....
    prog6.c:13: /opt/gnu/lib/gcc-lib/sparc-sunh:solaris2.8/3.3/include/stdarg.h:43: error: syntax error before "typedef"}
    Last edited by Meetee; Nov 10 '11, 04:27 AM. Reason: code tags added
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    The compiler found a problem before line 43 in stdarg.h.

    This is a standard C header that is included in stdio.h. These standard headers are compiler-specific and I don't have the one for your compiler. You might look there and post the code a little before and including line 43.

    Comment

    Working...