Ahoj, mam taky maly problem. Dostal som zadanie na programovanie vytvorit databazu v jazyku C a mam tu nasledujuci kod... nevedel by mi niekto poradit preco mi to hadze tie chyby co mi chadze? :) bol by som velmi povdacny :)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int menu()
{
int choice = 0;
do
{
printf("Welcome to the F1 database, please choose one of the following options:\n");
printf("\t Press 1 to update the driver's details.\n");
printf("\t Press 2 to enter the race results.\n");
printf("\t Press 3 to see the driver's current standings.\n");
printf("\t Press 4 to exit the program.\n");
scanf("%d", &choice);
}
while ((choice < 1) && (choice > 4));
{
printf("\a This is an invalid option, please try again.\n");
}
return choice;
}
int main()
{
int choice = 0;
int recordNum = 0;
Driver driver = {0};
do
{
choice = menu();
switch (choice)
{
case 1://Updating the driver's details
updatecurrentrecord(&driver);
addRecord(FILENAME, &driver);
break;
case 2://Entering the race results
//enterresults;
break;
case 3://Displaying the driver standings
printDriverstandings(listHead);
break;
default:
break;
}
}
while (choice != 4);
}
//Case 1
int updatecurrentrecord(const char *filename, int recordNum, Driver *driver)
{
int ret = 0;
int carnumber = 0;
FILE *file = fopen(filename, "r+b");
system("cls");
printf("Please enter the car number which you would like to add or update : ");
scanf("%d",driver->carnumber);
while ((carnumber < 1) || (carnumber > 26))
{
printf("Enter a valid car number between 1 and 26, please try again. \a \n");
scanf("%d",driver->carnumber);
}
fclose(file);
return ret;
}
void enterdriverdetails(Driver *driver);
{
if (fseek(file, sizeof(Driver) * carnumber, SEEK_SET) != 0)
{
FILE *file = fopen(filename, "w+b");
system("cls");
printf("The car number chosen has no details ");
printf("Please enter the driver's full name: ");
scanf("%s", driver->drivername);
printf("Please enter the car's constructor team name: ");
scanf("%s", driver->teamname);
printf("Please enter the number of points earned so far in the Formula 1 season: ");
scanf("%d", &driver->points);
}
}
int updatecurrentrecord(const char *filename, int recordNum, Driver *driver)
{
fopen(file);
if (fseek(file, sizeof(Driver) * recordNum, SEEK_SET) == 0)
{
system("cls");
printf("The car number chosen akready has a driver! Please choose one of the following options: \n");
printf("\t Press 0 to change the driver's name. \n");
printf("\t Press 1 to change the car's constructor team name. \n");
scanf("%d", &correctionchoice);
}
while ((correctionchoice < 0) || (correctionchoice > 1))
{
printf("Please enter a valid choice, please try again. \a \n");
}
if (correctionchoice == 0)
{
printf("Please enter the driver's new full name: ");
scanf("%s", driver->drivername);
}
else
{
printf("Please enter the car's new constructor team name: ");
scanf("%s", driver->teamname);
}
fclose(file);
return ret;
}