Databaza v jazyku C – C / C++ – Fórum – Programujte.com
 x   TIP: Přetáhni ikonu na hlavní panel pro připnutí webu

Databaza v jazyku C – C / C++ – Fórum – Programujte.comDatabaza v jazyku C – C / C++ – Fórum – Programujte.com

 

5. 4. 2012   #1
-
0
-

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;
}
Nahlásit jako SPAM
IP: 147.232.157.–
KIIV
~ Moderátor
+43
God of flame
5. 4. 2012   #2
-
0
-

   

db.c: In function ‘main’:
db.c:33:5: error: ‘Driver’ undeclared (first use in this function)
db.c:33:5: note: each undeclared identifier is reported only once for each function it appears in
db.c:33:12: error: expected ‘;’ before ‘driver’
db.c:41:13: warning: implicit declaration of function ‘updatecurrentrecord’
db.c:41:34: error: ‘driver’ undeclared (first use in this function)
db.c:42:13: warning: implicit declaration of function ‘addRecord’
db.c:42:23: error: ‘FILENAME’ undeclared (first use in this function)
db.c:50:13: warning: implicit declaration of function ‘printDriverstandings’
db.c:50:34: error: ‘listHead’ undeclared (first use in this function)
db.c:32:9: warning: unused variable ‘recordNum’
db.c: At top level:
db.c:63:62: error: expected declaration specifiers or ‘...’ before ‘Driver’
db.c: In function ‘updatecurrentrecord’:
db.c:71:16: error: ‘driver’ undeclared (first use in this function)
db.c: At top level:
db.c:83:32: error: expected ‘)’ before ‘*’ token
db.c:84:1: error: expected identifier or ‘(’ before ‘{’ token                                                                                                                          
db.c:100:62: error: expected declaration specifiers or ‘...’ before ‘Driver’                                                                                                           
db.c:100:5: error: redefinition of ‘updatecurrentrecord’                                                                                                                               
db.c:63:5: note: previous definition of ‘updatecurrentrecord’ was here                                                                                                                 
db.c: In function ‘updatecurrentrecord’:                                                                                                                                               
db.c:102:11: error: ‘file’ undeclared (first use in this function)                                                                                                                     
db.c:102:5: error: too few arguments to function ‘fopen’                                                                                                                               
/usr/include/stdio.h:269:14: note: declared here                                                                                                                                       
db.c:104:28: error: ‘Driver’ undeclared (first use in this function)                                                                                                                   
db.c:110:22: error: ‘correctionchoice’ undeclared (first use in this function)                                                                                                         
db.c:121:21: error: ‘driver’ undeclared (first use in this function)                                                                                                                   
db.c:131:12: error: ‘ret’ undeclared (first use in this function)                                                                                                                      
db.c:132:1: warning: control reaches end of non-void function                                                                                                                          
db.c: In function ‘main’:                                                                                                                                                              
db.c:59:1: warning: control reaches end of non-void function  

Snad to teda jeste nepotrebujes prelozit i do cestiny... ale napoveda k prvni chybe: WTF is Driver??

Nahlásit jako SPAM
IP: 62.168.56.–
Program vždy dělá to co naprogramujete, ne to co chcete...
ingiraxo+15
Grafoman
5. 4. 2012   #3
-
0
-

#2 KIIV
Mám dojem, že to někde skopíroval a teď řeší proč to nejde, když ani sám neví co tam všechno je

Nahlásit jako SPAM
IP: 46.183.64.–
Moje aplikace: http://ophite.cz
Tutoriály na: C#
KIIV
~ Moderátor
+43
God of flame
5. 4. 2012   #4
-
+1
-
Zajímavé

#3 ingiraxo
jo to je pravdepodobne... ani pro jistotu nedal ten seznam chyb, aby si to kazdy musel vykopirovat a kompilovat sam :)

Nahlásit jako SPAM
IP: 62.168.56.–
Program vždy dělá to co naprogramujete, ne to co chcete...
Franky238
~ Anonymní uživatel
8 příspěvků
5. 4. 2012   #5
-
0
-

NO viete to je tak :) ten profak co nas to ma ucit nas uci nieco ine ale pozaduje toto zadanie ... a nicomu nechapeme :/

Nahlásit jako SPAM
IP: 147.232.154.–
Zjistit počet nových příspěvků

Přidej příspěvek

Toto téma je starší jak čtvrt roku – přidej svůj příspěvek jen tehdy, máš-li k tématu opravdu co říct!

Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku

×Vložení zdrojáku

×Vložení obrázku

Vložit URL obrázku Vybrat obrázek na disku
Vlož URL adresu obrázku:
Klikni a vyber obrázek z počítače:

×Vložení videa

Aktuálně jsou podporována videa ze serverů YouTube, Vimeo a Dailymotion.
×
 
Podporujeme Gravatara.
Zadej URL adresu Avatara (40 x 40 px) nebo emailovou adresu pro použití Gravatara.
Email nikam neukládáme, po získání Gravatara je zahozen.
-
Pravidla pro psaní příspěvků, používej diakritiku. ENTER pro nový odstavec, SHIFT + ENTER pro nový řádek.
Sledovat nové příspěvky (pouze pro přihlášené)
Sleduj vlákno a v případě přidání nového příspěvku o tom budeš vědět mezi prvními.
Reaguješ na příspěvek:

Uživatelé prohlížející si toto vlákno

Uživatelé on-line: 0 registrovaných, 23 hostů

Podobná vlákna

C# a databaza — založil JannyM

Databaza — založil ing

Databáza v C++ — založil Anonymní uživatel

Databáza receptov :) — založil Tocimanko

Databaza v Jave — založil mienkofax

Moderátoři diskuze

 

Hostujeme u Českého hostingu       ISSN 1801-1586       ⇡ Nahoru Webtea.cz logo © 20032024 Programujte.com
Zasadilo a pěstuje Webtea.cz, šéfredaktor Lukáš Churý