Thread: new to C , error C2371: 'error" : redefinition; diffrent basic types

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    1

    new to C , error C2371: 'error" : redefinition; diffrent basic types

    Hello, i've to submit this assigment in few hours and i'm very nervous,
    it's sort of Gas Station managing programs, handeling input files, and printing results...
    it's only 1 .c file and that's my first code lines, which defines the structs:

    Code:
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    
    
    
    struct Gas_Station *pgasStationHead = NULL;
    typedef struct Gas_Station {
      	char *name;
      	double octan95SS;
    	double octan95FS;
    	double octan98SS;
    	double octan98FS;
    	double gasSoldTotal;
    	double gasSoldSS;
    	double gasSoldFS;
    	struct Gas_Station* pgasStationNext;
    	struct Client_List* pclientHead;
    } Station;
      
    typedef struct Client_List {
      	char carID[10];
    	char gasType[3];
      	double gasAmount;
    	char serviceType[12];
    	struct Client_List* pclientNext;
    } Client;
    and those are the problematic functions and the main :
    Code:
    void CommandsSwitch(char *orders)	{
    	FILE *input , *output;
    	input = fopen(orders, "rt");
    	output = fopen("result.txt" , "wt");
    	if (input == NULL)	{
    			error("can't open file, might not exists");
    	}
    	else if	(output == NULL)	{
    			error("can't open file");
    	}
    	else	{
    		do	{
    			int i;
    			char *ptemp, *pfuncNum, *pcarID , *pstationName;
    			
    			ptemp = fgets(ptemp , 80 , input);
    			if (ptemp[0] != '#')	{
    				pfuncNum = strtok(ptemp , ",");
    				i = (int)pfuncNum[0];
    				switch (i)
    				{
    					case 1:
    					HowMuchGasPerStation(output);
    					break;
    					
    					case 2 :
    					pstationName = strtok(pstationName , ",");
    					AverageGasInSpecieficStation(output , pstationName);
    					break;
    					
    					case 3 :
    					HowMuchGasInAllStations(output);
    					break;
    					
    					case 4 :
    					HowMuchGasFSInAllStations(output);
    					break;
    					
    					case 5 :
    					pcarID = strtok(ptemp , ",");
    					HowMuchGasSoldByCarID(output , pcarID);
    					break;
    					case 6 :
    					pcarID = strtok(ptemp , ",");
    					pstationName = strtok(pstationName , ",");
    					HowMuchGasSoldByStationPerCarID(output , pcarID , pstationName);
    					break;
    					case 7 :
    					pcarID = strtok(ptemp , ",");
    					StationsWithClientByCarID(output , pcarID);
    					break;
    					case 8 :
    					pcarID = strtok(ptemp , ",");
    					pstationName = strtok(pstationName , ",");
    					HowMuchClientSpentByStation(output , pcarID , pstationName);
    					break;
    					case 9 :
    					pcarID = strtok(ptemp , ",");
    					HowMuchClientSpentInTotalByCarID(output , pcarID);
    					break;
    					
    					case 10 :
    					pstationName = strtok(pstationName , ",");
    					ClientDetailsBySpecieficStation(output , pstationName);
    					break;
    				}
    			}
    		}while(!feof(input));	
    	}
    	fclose(input);
    	fclose(output);
    }
    
    static void error(char *msg)	{
    	fprintf(stderr , "Error: %s\n", msg);
    	exit(1);
    }
    
    int main (int argc, char* argv[])	{
    	int i;
    	FILE *f;
    	char *orders = argv[1];
    	for (i = 2; i < argc; i++)	{
    		f = fopen(argv[i] , "rt");
    		if (f == NULL)	{
    			error("can't open file, might not exists");
    		}
    		else	{
    			AddStation(f);
    		}
    		fclose(f);
    	}
    	CommandsSwitch(orders);
    
    }
    now the error points to the " static void error(char *msg) " function but before that it pointed to " void CommandsSwitch(char *orders) " , the CommandsSwitch give the same error.

    plz try to help and guide me, i'm confused.
    tnx.
    Last edited by kubebm; 11-15-2010 at 11:14 AM.

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    You can either mess around with figuring out what order to lay the functions out in, or you can just add some function prototypes near the top of the file.
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [ANN] New script engine (Basic sintax)
    By MKTMK in forum C++ Programming
    Replies: 1
    Last Post: 11-01-2005, 10:28 AM
  2. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM
  3. Basic Data types help
    By viryonia in forum C Programming
    Replies: 6
    Last Post: 03-10-2003, 11:00 AM
  4. Basic Data types continue
    By viryonia in forum C Programming
    Replies: 6
    Last Post: 03-10-2003, 10:21 AM