Thread: Function

  1. #1
    Registered User
    Join Date
    Apr 2020
    Posts
    8

    Function

    The entire code does everything I want but I can not get the results function to work properly i know its a simple error probably something with brackets but I can not figure it out.

    this is the results function
    Code:
    int results(struct cars *resultspointer, int size)
    {
    
    
    	struct cars temp;
    	int x,y;
    
    
    	/* seed the randomizer */
    	srand( (unsigned)time(NULL));
    	int write=0;
    	int player1=0;
    	int player2;
    
    
    
    
    
    
    	/* sort the scores */
    	for(x=0;x<CARS_ARRAY_SIZE;x++){
            for(y=x+1;y<size;y++){
                if((resultspointer+x)->(distance)<((resultspointer+y)->(distance)))
    			{
    				temp = ((resultspointer+x)->(distance));
    				player[x] = ((resultspointer+x)->(distance));
    				player[y] = (resultspointer+y)->(distance);
    			}
            }
        }
    
    
    
    
    
    
    	/* display the results */
    	puts("Round Results:");
    	for(x=0;x<PLAYERS;x++)
        {
            printf("#%d %s, score %d\n",x+1);
    				((resultspointer+x)->(name));
    				((resultspointer+x)->(distance));
            write=writeCarsTXT(CARS_ARRAY_SIZE, results);
        }
    
    
    
    
    
    
    }



    Code:
    //libraries
    #include <stdio.h>
    #include <time.h>
    #include <ctype.h>
    #include <stdlib.h>
    #include <math.h>
    #include <string.h>
    #include <windows.h>
    //constant of array size
    #define CARS_ARRAY_SIZE 4
    #define MAXR 10
    #define MINR 1
    #define MAXC 4
    #define MINC 0
    #define PLAYERS 6
    
    
    // this structure is pretty much called in every function I made
    struct cars
    {
        char name[20];
        char make[20];
        int car_number;
        char color[20];
        int distance;
        int RCinfo[4];
    };
    
    
    //prototypes
    int car_pic(struct cars *carpointer, int size);
    int Modify(struct cars *modpointer, int size, int CarSelect);
    int readCarsTXT (struct cars *readpointer, int size);
    int manual ();
    int automatic();
    int movement (struct cars *movementpointer, int size);
    
    
     int main (void)
    {
        //declaring variables in array
        int i=0;
        int lower=0;
        int upper=10;
        int count=1;
        int automaticmovement;
        int manualmovement;
        int AutoOrManual;
        int CarType;
        int number;
        int CarColor;
        char DriverName;
        int manualrace;
        int v1;
        int v2;
        int modifyorstart;
        int automatic2;
        int ExitFlag=0;
    
    
        //opening file for arrays
        FILE *fPointerCars;
        srand(time(NULL));//
      //Print name and explain this is a racing game
      printf("RoseEllen Hoke\n This is a race car game a text base game that races 4 cars across the screen and determines \n the first second and third place.A text file (car.txt) with the name of the driver, type of \n the race car, car number, and the color of the car is given to you.\n\n");
                    printf("\n\n******Welcome to Nascar Soccer Mom Edition*******\n\n");
    
    
      do
      {
          //this lets the user choose wether they want to race manually or automatic or exit
          //struct cars AutoManual[CARS_ARRAY_SIZE];
          printf("\n enter 1 if you want race against another user \n enter 2 if you want to race against 4 cars automatically \n enter 3 to exit");
          scanf("%d",&AutoOrManual);
          switch(AutoOrManual)
          {
            case 1:
            //calls manual function
            printf("You have selected Manual\n");
                manual();
            //CAll Function that runs that type of race
            break;
            case 2:
                //calls automatic function
            printf("You have selected Automatic\n");
               automatic();
            break;
            case 3:
                //exits game
                printf("EXIT");
                ExitFlag=1;
            default:
                //allows the user to choose again if they do not enter 1,2 or 3
                printf("please enter a valid number");
            break;
          }
    
    
    
    
    
    
      }while(ExitFlag==0);
    
    
    
    
     return 0;
    }
    
    
    //function for automatic cars allows the user to modify there car, start the game or exit
    int automatic ()
    {
        //array
        struct cars AutoCars[4];
    
    
        //variables
        int CarSelection=0;
        int CarModify=0;
        int start=0;
        int racestart=0;
        int CarStart=0;
        int Exitflag=0;
        int modifyyourstart;
        int playeroneortwo;
        int results=0;
        int player1;
        int player2;
        int total1;
        //readCarsTXT()
        readCarsTXT(AutoCars, CARS_ARRAY_SIZE);
        CarSelection=car_pic(AutoCars,CARS_ARRAY_SIZE);
        //readCarsTXT(ModifyCars, CARS_ARRAY_SIZE);
        //readCarsTXT(StartCars, CARS_ARRAY_SIZE);
        //CarStart=
        do{
            printf("press 1 if you would like to modify your car or press 2 if you would like to start the game or press 3 to exit the menu");
            scanf("%d",&modifyyourstart);
            switch (modifyyourstart)
            {//Ask user whether they want to mod car or start or exit
                case 1:
                    CarModify=Modify(AutoCars,CARS_ARRAY_SIZE,CarSelection);
                break;
                case 2:
                    start=AutoRunRace(AutoCars, CARS_ARRAY_SIZE);
    
    
                break;
                case 3:
                    printf("Exiting the menu");
                    Exitflag=1;
                default:
                    printf("please enter a valid number");
                break;
            }
        }while(Exitflag==0);
    
    
    
    
    results=writeCarsTXT(AutoCars,CARS_ARRAY_SIZE);
     scanf("%d,%d", player1,player2);
        printf("First place had a time of %d\n Second place had a time of %d", total1);
    
    
    
    
    
    
    
    
    }
    //function for manual allows user to choose what player they are either play 1 or 2 and then allows them to modify both cars and start game
    int manual()
    {
        //variables
        int player1, player2;
        int total1, total2;
        time_t t;
        char ans;
        struct cars Race[4];
        struct cars ManualRace[2];
        int playerone=0;
        int playertwo=0;
        int CarSelection=0;
        int CarModify=0;
        int CarStart=0;
        int Exitflag=0;
        int results=0;
        int modifyorstart;
        int playeroneortwo;
        int start=0;
        int racestart=0;
    
    
    
    
        readCarsTXT(Race, CARS_ARRAY_SIZE);
        playerone=car_pic(Race,CARS_ARRAY_SIZE);
        playertwo=car_pic(Race,CARS_ARRAY_SIZE);
    
    
        //Copy the race array to the manua rae array
        strcpy(ManualRace[0].name,Race[playerone].name);
        strcpy(ManualRace[0].make,Race[playerone].make);
        ManualRace[0].car_number=Race[playerone].car_number;
        strcpy(ManualRace[0].color,Race[playerone].color);
    
    
        strcpy(ManualRace[1].name,Race[playertwo].name);
        strcpy(ManualRace[1].make,Race[playertwo].make);
        ManualRace[1].car_number=Race[playertwo].car_number;
        strcpy(ManualRace[1].color,Race[playertwo].color);
        //scanf(carFilePointer,"%s %s %d %s",readpointer-> name, readpointer-> make, &readpointer->car_number, readpointer-> color);
         do{
            printf("press 1 if you would like to modify your car or press 2 if you would like to start the game or press 3 to exit the menu");
            scanf("%d", &modifyorstart);
            switch (modifyorstart)
            {// Ask here whether they want to mod car or start
                case 1:
                    printf("enter 1 if you are player one or enter 2 if you are player two");
                    scanf("%d", &modifyorstart);
                    switch(playeroneortwo)
                    {
                        case 1:
                            CarModify=Modify(ManualRace,CARS_ARRAY_SIZE, playerone);
                        break;
                        case 2: CarModify=Modify(ManualRace,CARS_ARRAY_SIZE, playertwo);
                        break;
    
    
                    }
                   // CarModify=Modify(ManualRace,CARS_ARRAY_SIZE, playerone);
    
    
                break;
                case 2:
                    start=AutoRunRace(ManualRace, CARS_ARRAY_SIZE);
    
    
                break;
                case 3:
                    printf("Exiting the menu");
                    Exitflag=1;
                default:
                    printf("please enter a valid number");
                break;
            }
           results=writeCarsTXT(ManualRace,CARS_ARRAY_SIZE);
    
    
        }while(Exitflag==0);
    //generates random numbers
        srand(time(&t));
    //generates number 0-3
        player1 = (rand()% 3)+1;
        player2 - (rand()% 3)+1;
        total1= player1 + player2;
        scanf("%d,%d", player1,player2);
        printf("First place had a time of %d\n Second place had a time of %d", total1);
    
    
    
    
    }
    
    
    //function that creates a random number for the moves and the car
    int RandGenerator(int Max, int Min)
    {
        int randnum=0;
        //int MAXV=10;
        //int MINV=1;
    
    
        randnum=( rand() % (Max-Min))+ Min ;
        //printf("%d\n", randnum);
        return randnum;
    
    
    }
    
    
    //this functions runs the race by using the random number generator and picking a number defined by the constatnts at the begining
    int AutoRunRace(struct cars *racer, int size)
    {
        int FinishFlag=0;
        int RandCar;
        int RandDist;
        int i,j;
        for(i=0;i<4;i++)
        {
            (racer+i)->distance=0;
        }
        do
        {
            RandCar= RandGenerator(MAXC, MINC);
            RandDist= RandGenerator(MAXR, MINR);
            (racer+RandCar)->distance+=RandDist;
            for(i=0;i<4;i++)
            {
                printf("%d", (racer+i)-> car_number);
                for(j=0;j<(racer+i)->distance;j++)
                {
                    printf("*");
    
    
    
    
                }
                if((racer+i)->distance>=90)
                    {
                        FinishFlag=1;
                    }
                printf("\n");
            }
        }while(FinishFlag==0);
    }
    //This fuctnio writes to the txt file raceresults
    int writeCarsTXT(struct cars *resultspointer, int size)
    {
        int num;
        FILE *resultsfptr;
        resultsfptr = fopen("raceresults.txt", "w");
    
    
    int i=0, results=0;
        // display cars
        for (i=0; i < size; i++)
        {
    
    
            printf("%d- %-12s %-12s %-3d %-12s\n", i+1, resultspointer-> name, resultspointer-> make, resultspointer->car_number, resultspointer-> color);
            // pointer arithmetic. point to the next array element
            resultspointer++;
        }
    
    
        scanf("%d", &results);
        // assign array index to chosen_car and return
        results --;
        return results;
    
    
    
    
    
    
    
    
    
    
        if(resultsfptr == NULL)
        {
            printf("no winners");
            exit(1);
        }
        printf("\n first place is: %d\n second place is: %d\n third place is: %d\n ");
        scanf("%d",&num);
    
    
    
    
        fprintf(resultsfptr,"%d", num);
        fclose(resultsfptr);
    }
    
    
    
    
    // this function allows the user to pick a car from the text file car
    int car_pic(struct cars *carpointer, int size)
    {
    
    
        int i=0, chosen_car=0;
        // display cars
        for (i=0; i < size; i++)
        {
    
    
            printf("%d- %-12s %-12s %-3d %-12s\n", i+1, carpointer-> name, carpointer-> make, carpointer->car_number, carpointer-> color);
            // pointer arithmetic. point to the next array element
            carpointer++;
        }
        printf("\nEnter the number that correlates to what car you want");
        scanf("%d", &chosen_car);
        // assign array index to chosen_car and return
        chosen_car --;
        return chosen_car;
    }
    
    
    
    
    // this allows the user to modify there name, make of the car, number and color
    int Modify(struct cars *modpointer, int size, int CarSelect)
    {
        //variables
        int i= CarSelect;
        char CarType1[20];
        char DriverName[20];
        int numberA;
        int menu=0;
        char CarColor1[20];
        int ExitMod=0;
        do{
             //You should have this is a Do while and have a case to exit the modifications
            printf("Please select your modification\n enter 1 for name\n enter 2 for a make\n enter 3 for a number\n enter 4 for a color\n enter 5 to exit");
            scanf("%d", &menu);
           switch(menu)
           {
            case 1:
                printf("\n please enter driver name");
                scanf("%s", DriverName);
                strcpy((modpointer+i)->name, DriverName);
                break;
            case 2:
                printf("please enter the type of car you want");
                scanf("%s", CarType1);
                strcpy ((modpointer+i)->make, CarType1);
                break;
            case 3:
                printf("\nplease enter the number you want");
                scanf("%d", numberA);
                ((modpointer+i)->car_number=numberA);
                break;
            case 4:
                printf("please enter the color you want your car");
                scanf("%s", &CarColor1);
                strcpy((modpointer+i)->color, CarColor1);
                break;
            case 5:
                printf("Exit modification");
                ExitMod=1;
                break;
    
    
            default:
                printf("Wrong INput");
           }
    
    
    
    
        }while(ExitMod==0);
    }
    
    
    
    
    
    
        //This function reads the cars. txt file
        //and is passed from a function to a structure
    int readCarsTXT(struct cars *readpointer, int size)
    {
        // declaring variables
        int i=0;
        FILE *carFilePointer;
        carFilePointer = fopen("car.txt", "r");
    
    
        // check  existence of the file
        if (carFilePointer == NULL)
        {
            printf("file does not exist");
        }
        else
        {
            // reads the file and assign data to array of structures
            for (i=0; i < CARS_ARRAY_SIZE; i++)
            {
                fscanf(carFilePointer,"%s %s %d %s",readpointer-> name, readpointer-> make, &readpointer->car_number, readpointer-> color);
                // pointer arithmetic. point to the next array element
                readpointer++;
            }
    
    
            // call car_pic function
        }
        close(carFilePointer);
    }
    
    
    int results(struct cars *resultspointer, int size)
    {
    
    
        struct cars temp;
        int x,y;
    
    
        /* seed the randomizer */
        srand( (unsigned)time(NULL));
        int write=0;
        int player1=0;
        int player2;
    
    
    
    
    
    
        /* sort the scores */
        for(x=0;x<CARS_ARRAY_SIZE;x++){
            for(y=x+1;y<size;y++){
                if((resultspointer+x)->(distance)<((resultspointer+y)->(distance)))
                {
                    temp = ((resultspointer+x)->(distance));
                    player[x] = ((resultspointer+x)->(distance));
                    player[y] = (resultspointer+y)->(distance);
                }
            }
        }
    
    
    
    
    
    
        /* display the results */
        puts("Round Results:");
        for(x=0;x<PLAYERS;x++)
        {
            printf("#%d %s, score %d\n",x+1);
                    ((resultspointer+x)->(name));
                    ((resultspointer+x)->(distance));
            write=writeCarsTXT(CARS_ARRAY_SIZE, results);
        }
    
    
    
    
    
    
    }
    Last edited by carolbaskin; 04-21-2020 at 05:47 PM.

  2. #2
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,875
    This is what I got when I tried to build it...
    Code:
      ||=== Build: Debug in AlgorithmTest (compiler: GNU GCC Compiler) ===|
    D:\Programming\AlgorithmTest\main.c||In function 'main':|
    D:\Programming\AlgorithmTest\main.c|62|warning: unused variable 'fPointerCars' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|57|warning: unused variable 'automatic2' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|56|warning: unused variable 'modifyorstart' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|55|warning: unused variable 'v2' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|54|warning: unused variable 'v1' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|53|warning: unused variable 'manualrace' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|52|warning: unused variable 'DriverName' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|51|warning: unused variable 'CarColor' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|50|warning: unused variable 'number' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|49|warning: unused variable 'CarType' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|47|warning: unused variable 'manualmovement' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|46|warning: unused variable 'automaticmovement' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|45|warning: unused variable 'count' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|44|warning: unused variable 'upper' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|43|warning: unused variable 'lower' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|42|warning: unused variable 'i' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c||In function 'automatic':|
    D:\Programming\AlgorithmTest\main.c|147|error: implicit declaration of function 'AutoRunRace' [-Wimplicit-function-declaration]|
    D:\Programming\AlgorithmTest\main.c|163|error: implicit declaration of function 'writeCarsTXT' [-Wimplicit-function-declaration]|
    D:\Programming\AlgorithmTest\main.c|164|warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]|
    D:\Programming\AlgorithmTest\main.c|164|warning: format '%d' expects argument of type 'int *', but argument 3 has type 'int' [-Wformat=]|
    D:\Programming\AlgorithmTest\main.c|128|warning: variable 'results' set but not used [-Wunused-but-set-variable]|
    D:\Programming\AlgorithmTest\main.c|127|warning: unused variable 'playeroneortwo' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|124|warning: unused variable 'CarStart' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|123|warning: unused variable 'racestart' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|122|warning: variable 'start' set but not used [-Wunused-but-set-variable]|
    D:\Programming\AlgorithmTest\main.c|121|warning: variable 'CarModify' set but not used [-Wunused-but-set-variable]|
    D:\Programming\AlgorithmTest\main.c||In function 'manual':|
    D:\Programming\AlgorithmTest\main.c|259|warning: value computed is not used [-Wunused-value]|
    D:\Programming\AlgorithmTest\main.c|261|warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]|
    D:\Programming\AlgorithmTest\main.c|261|warning: format '%d' expects argument of type 'int *', but argument 3 has type 'int' [-Wformat=]|
    D:\Programming\AlgorithmTest\main.c|195|warning: unused variable 'racestart' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|194|warning: variable 'start' set but not used [-Wunused-but-set-variable]|
    D:\Programming\AlgorithmTest\main.c|191|warning: variable 'results' set but not used [-Wunused-but-set-variable]|
    D:\Programming\AlgorithmTest\main.c|189|warning: unused variable 'CarStart' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|188|warning: variable 'CarModify' set but not used [-Wunused-but-set-variable]|
    D:\Programming\AlgorithmTest\main.c|187|warning: unused variable 'CarSelection' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|182|warning: unused variable 'ans' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|180|warning: unused variable 'total2' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c||In function 'AutoRunRace':|
    D:\Programming\AlgorithmTest\main.c|287|warning: unused parameter 'size' [-Wunused-parameter]|
    D:\Programming\AlgorithmTest\main.c||In function 'Modify':|
    D:\Programming\AlgorithmTest\main.c|427|warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]|
    D:\Programming\AlgorithmTest\main.c|432|warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[20]' [-Wformat=]|
    D:\Programming\AlgorithmTest\main.c|399|warning: unused parameter 'size' [-Wunused-parameter]|
    D:\Programming\AlgorithmTest\main.c||In function 'readCarsTXT':|
    D:\Programming\AlgorithmTest\main.c|484|error: implicit declaration of function 'close' [-Wimplicit-function-declaration]|
    D:\Programming\AlgorithmTest\main.c|458|warning: unused parameter 'size' [-Wunused-parameter]|
    D:\Programming\AlgorithmTest\main.c||In function 'results':|
    D:\Programming\AlgorithmTest\main.c|510|error: expected identifier before '(' token|
    D:\Programming\AlgorithmTest\main.c|512|error: expected identifier before '(' token|
    D:\Programming\AlgorithmTest\main.c|513|error: 'player' undeclared (first use in this function)|
    D:\Programming\AlgorithmTest\main.c|513|note: each undeclared identifier is reported only once for each function it appears in|
    D:\Programming\AlgorithmTest\main.c|513|error: expected identifier before '(' token|
    D:\Programming\AlgorithmTest\main.c|514|error: expected identifier before '(' token|
    D:\Programming\AlgorithmTest\main.c|529|error: expected identifier before '(' token|
    D:\Programming\AlgorithmTest\main.c|530|error: expected identifier before '(' token|
    D:\Programming\AlgorithmTest\main.c|10|error: passing argument 1 of 'writeCarsTXT' makes pointer from integer without a cast [-Wint-conversion]|
    D:\Programming\AlgorithmTest\main.c|531|note: in expansion of macro 'CARS_ARRAY_SIZE'|
    D:\Programming\AlgorithmTest\main.c|322|note: expected 'struct cars *' but argument is of type 'int'|
    D:\Programming\AlgorithmTest\main.c|531|error: passing argument 2 of 'writeCarsTXT' makes integer from pointer without a cast [-Wint-conversion]|
    D:\Programming\AlgorithmTest\main.c|322|note: expected 'int' but argument is of type 'int (*)(struct cars *, int)'|
    D:\Programming\AlgorithmTest\main.c|500|warning: unused variable 'player2' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|499|warning: unused variable 'player1' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|498|warning: variable 'write' set but not used [-Wunused-but-set-variable]|
    D:\Programming\AlgorithmTest\main.c|492|warning: variable 'temp' set but not used [-Wunused-but-set-variable]|
    D:\Programming\AlgorithmTest\main.c||In function 'automatic':|
    D:\Programming\AlgorithmTest\main.c|174|warning: control reaches end of non-void function [-Wreturn-type]|
    D:\Programming\AlgorithmTest\main.c||In function 'manual':|
    D:\Programming\AlgorithmTest\main.c|267|warning: control reaches end of non-void function [-Wreturn-type]|
    D:\Programming\AlgorithmTest\main.c||In function 'AutoRunRace':|
    D:\Programming\AlgorithmTest\main.c|320|warning: control reaches end of non-void function [-Wreturn-type]|
    D:\Programming\AlgorithmTest\main.c||In function 'Modify':|
    D:\Programming\AlgorithmTest\main.c|449|warning: control reaches end of non-void function [-Wreturn-type]|
    D:\Programming\AlgorithmTest\main.c||In function 'readCarsTXT':|
    D:\Programming\AlgorithmTest\main.c|485|warning: control reaches end of non-void function [-Wreturn-type]|
    D:\Programming\AlgorithmTest\main.c||In function 'results':|
    D:\Programming\AlgorithmTest\main.c|539|warning: control reaches end of non-void function [-Wreturn-type]|
    ||=== Build failed: 12 error(s), 50 warning(s) (0 minute(s), 1 second(s)) ===|
    One thing I can see
    Code:
    scanf("%d,%d", player1,player2);
    // should be
    scanf("%d,%d", &player1, &player2);
    Take some time to work through each error/warning
    Fact - Beethoven wrote his first symphony in C

  3. #3
    Registered User Sir Galahad's Avatar
    Join Date
    Nov 2016
    Location
    The Round Table
    Posts
    174
    Quote Originally Posted by Click_here View Post
    This is what I got when I tried to build it...
    Code:
      ||=== Build: Debug in AlgorithmTest (compiler: GNU GCC Compiler) ===|
    D:\Programming\AlgorithmTest\main.c||In function 'main':|
    D:\Programming\AlgorithmTest\main.c|62|warning: unused variable 'fPointerCars' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|57|warning: unused variable 'automatic2' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|56|warning: unused variable 'modifyorstart' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|55|warning: unused variable 'v2' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|54|warning: unused variable 'v1' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|53|warning: unused variable 'manualrace' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|52|warning: unused variable 'DriverName' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|51|warning: unused variable 'CarColor' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|50|warning: unused variable 'number' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|49|warning: unused variable 'CarType' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|47|warning: unused variable 'manualmovement' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|46|warning: unused variable 'automaticmovement' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|45|warning: unused variable 'count' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|44|warning: unused variable 'upper' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|43|warning: unused variable 'lower' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|42|warning: unused variable 'i' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c||In function 'automatic':|
    D:\Programming\AlgorithmTest\main.c|147|error: implicit declaration of function 'AutoRunRace' [-Wimplicit-function-declaration]|
    D:\Programming\AlgorithmTest\main.c|163|error: implicit declaration of function 'writeCarsTXT' [-Wimplicit-function-declaration]|
    D:\Programming\AlgorithmTest\main.c|164|warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]|
    D:\Programming\AlgorithmTest\main.c|164|warning: format '%d' expects argument of type 'int *', but argument 3 has type 'int' [-Wformat=]|
    D:\Programming\AlgorithmTest\main.c|128|warning: variable 'results' set but not used [-Wunused-but-set-variable]|
    D:\Programming\AlgorithmTest\main.c|127|warning: unused variable 'playeroneortwo' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|124|warning: unused variable 'CarStart' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|123|warning: unused variable 'racestart' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|122|warning: variable 'start' set but not used [-Wunused-but-set-variable]|
    D:\Programming\AlgorithmTest\main.c|121|warning: variable 'CarModify' set but not used [-Wunused-but-set-variable]|
    D:\Programming\AlgorithmTest\main.c||In function 'manual':|
    D:\Programming\AlgorithmTest\main.c|259|warning: value computed is not used [-Wunused-value]|
    D:\Programming\AlgorithmTest\main.c|261|warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]|
    D:\Programming\AlgorithmTest\main.c|261|warning: format '%d' expects argument of type 'int *', but argument 3 has type 'int' [-Wformat=]|
    D:\Programming\AlgorithmTest\main.c|195|warning: unused variable 'racestart' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|194|warning: variable 'start' set but not used [-Wunused-but-set-variable]|
    D:\Programming\AlgorithmTest\main.c|191|warning: variable 'results' set but not used [-Wunused-but-set-variable]|
    D:\Programming\AlgorithmTest\main.c|189|warning: unused variable 'CarStart' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|188|warning: variable 'CarModify' set but not used [-Wunused-but-set-variable]|
    D:\Programming\AlgorithmTest\main.c|187|warning: unused variable 'CarSelection' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|182|warning: unused variable 'ans' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|180|warning: unused variable 'total2' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c||In function 'AutoRunRace':|
    D:\Programming\AlgorithmTest\main.c|287|warning: unused parameter 'size' [-Wunused-parameter]|
    D:\Programming\AlgorithmTest\main.c||In function 'Modify':|
    D:\Programming\AlgorithmTest\main.c|427|warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]|
    D:\Programming\AlgorithmTest\main.c|432|warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[20]' [-Wformat=]|
    D:\Programming\AlgorithmTest\main.c|399|warning: unused parameter 'size' [-Wunused-parameter]|
    D:\Programming\AlgorithmTest\main.c||In function 'readCarsTXT':|
    D:\Programming\AlgorithmTest\main.c|484|error: implicit declaration of function 'close' [-Wimplicit-function-declaration]|
    D:\Programming\AlgorithmTest\main.c|458|warning: unused parameter 'size' [-Wunused-parameter]|
    D:\Programming\AlgorithmTest\main.c||In function 'results':|
    D:\Programming\AlgorithmTest\main.c|510|error: expected identifier before '(' token|
    D:\Programming\AlgorithmTest\main.c|512|error: expected identifier before '(' token|
    D:\Programming\AlgorithmTest\main.c|513|error: 'player' undeclared (first use in this function)|
    D:\Programming\AlgorithmTest\main.c|513|note: each undeclared identifier is reported only once for each function it appears in|
    D:\Programming\AlgorithmTest\main.c|513|error: expected identifier before '(' token|
    D:\Programming\AlgorithmTest\main.c|514|error: expected identifier before '(' token|
    D:\Programming\AlgorithmTest\main.c|529|error: expected identifier before '(' token|
    D:\Programming\AlgorithmTest\main.c|530|error: expected identifier before '(' token|
    D:\Programming\AlgorithmTest\main.c|10|error: passing argument 1 of 'writeCarsTXT' makes pointer from integer without a cast [-Wint-conversion]|
    D:\Programming\AlgorithmTest\main.c|531|note: in expansion of macro 'CARS_ARRAY_SIZE'|
    D:\Programming\AlgorithmTest\main.c|322|note: expected 'struct cars *' but argument is of type 'int'|
    D:\Programming\AlgorithmTest\main.c|531|error: passing argument 2 of 'writeCarsTXT' makes integer from pointer without a cast [-Wint-conversion]|
    D:\Programming\AlgorithmTest\main.c|322|note: expected 'int' but argument is of type 'int (*)(struct cars *, int)'|
    D:\Programming\AlgorithmTest\main.c|500|warning: unused variable 'player2' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|499|warning: unused variable 'player1' [-Wunused-variable]|
    D:\Programming\AlgorithmTest\main.c|498|warning: variable 'write' set but not used [-Wunused-but-set-variable]|
    D:\Programming\AlgorithmTest\main.c|492|warning: variable 'temp' set but not used [-Wunused-but-set-variable]|
    D:\Programming\AlgorithmTest\main.c||In function 'automatic':|
    D:\Programming\AlgorithmTest\main.c|174|warning: control reaches end of non-void function [-Wreturn-type]|
    D:\Programming\AlgorithmTest\main.c||In function 'manual':|
    D:\Programming\AlgorithmTest\main.c|267|warning: control reaches end of non-void function [-Wreturn-type]|
    D:\Programming\AlgorithmTest\main.c||In function 'AutoRunRace':|
    D:\Programming\AlgorithmTest\main.c|320|warning: control reaches end of non-void function [-Wreturn-type]|
    D:\Programming\AlgorithmTest\main.c||In function 'Modify':|
    D:\Programming\AlgorithmTest\main.c|449|warning: control reaches end of non-void function [-Wreturn-type]|
    D:\Programming\AlgorithmTest\main.c||In function 'readCarsTXT':|
    D:\Programming\AlgorithmTest\main.c|485|warning: control reaches end of non-void function [-Wreturn-type]|
    D:\Programming\AlgorithmTest\main.c||In function 'results':|
    D:\Programming\AlgorithmTest\main.c|539|warning: control reaches end of non-void function [-Wreturn-type]|
    ||=== Build failed: 12 error(s), 50 warning(s) (0 minute(s), 1 second(s)) ===|
    One thing I can see
    Code:
    scanf("%d,%d", player1,player2);
    // should be
    scanf("%d,%d", &player1, &player2);
    Take some time to work through each error/warning
    Yep. Write a little code, compile and run, inspect the output. Rinse and repeat...
    The power of null.

  4. #4
    Registered User
    Join Date
    Apr 2020
    Posts
    8
    got it all to work thank you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 02-19-2020, 05:50 AM
  2. Function Prototype, Function Call, and Function definition
    By dmcarpenter in forum C Programming
    Replies: 9
    Last Post: 04-09-2013, 03:29 AM
  3. Replies: 13
    Last Post: 03-20-2012, 08:29 AM
  4. Print function: sending a function.. through a function?
    By scarlet00014 in forum C Programming
    Replies: 3
    Last Post: 11-05-2008, 05:03 PM
  5. Replies: 9
    Last Post: 01-02-2007, 04:22 PM

Tags for this Thread