Monday, July 27, 2009

Programming Database Program in Dev C++?

#include %26lt;stdio.h%26gt;





void fileChecker (char filename[20]);





char choice, menu, restart, filename[20], option, buffer;


int i, j, n, m, cnt = 0, flag;


FILE *fp;





struct record{


char lastName[20];


char firstName[20];


char cacNum[10];


} , tmp;





void main(int argc, char *argv[])


{


clrscr();


printf("Welcome to the Student Database!");


printf("\n\nPlease enter the following information:");


n = 0;


do{


printf("\n\nLastname: ");


printf("Firstname: ");


gets(student[n].firstname);


printf("CAC Number: ");


do{


printf("\nDo you wish to add another entry? (y/n) ");


choice = tolower(());


if(choice) == 'y')


{


n++;


}


}

Programming Database Program in Dev C++?
I HAVE MADE SOME COMMENTS BELOW...





void fileChecker (char filename[20]);





char choice, menu, restart, filename[20], option, buffer;


int i, j, n, m, cnt = 0, flag;


FILE *fp;





struct record{


char lastName[20];


char firstName[20];


char cacNum[10];


} , tmp;





void main(int argc, char *argv[])


{


clrscr();


printf("Welcome to the Student Database!");


printf("\n\nPlease enter the following information:");


n = 0;


do


{


printf("\n\nLastname: ");


printf("Firstname: ");


gets(student[n].firstname); YOU DECALRE TMP FOR THE STUCT, ARE YOU USING IT?


WHAT ABOUT LAST NAME?? GET IT??


printf("CAC Number: "); WHAT ABOUT CAC, GET IT??


do


{


printf("\nDo you wish to add another entry? (y/n) ");


choice = tolower(());


if(choice) == 'y')


{


n++;


}


}


}


while(choice != 'n');


n++; IF ITS NOT == THEN N++?? AGAIN





if(argc %26gt; 1)





{


( WHY IS THERE A PARENS HERE?


filename, argv[1];


fileChecker(filename);


}


else


{


printf(\n\nYou have not provided the Record Filename...");


retrieverFilename();


}


OKAY......FIRST YOU HAVE TO GO THROUGH THIS AND MAKE SURE ALL THE BRACES MATCH, COMMENT THEM,


ITS WAY TO HARD TO READ AND UNDERSTAND.


MAKE SURE YOU ARE GETTING THE INFO FROM THE USER AND PUTTING IT INSIDE YOUR ARRAYS,


REFORMAT THIS THING SO YOU CAN READ IT EASIER....THERE ARE MANY BRACES WHERE THERE SHOULDN'T BE AND EXTRA PARENS AND EXTRA BRACES..














fcloseall();


printf("\nSaving Completed!");


printf("\nThank You!");


do


{


print("\n\nDo you wish to restart the program? (y/n) ");


restart = (getche());


}


}








else


{


printf("\nGoodbye!");


exit(1);


}


}


/*************************************...


void retrieverFilename()


{


printf('\n\nEnter the Record Filename: ");


gets(filename);


fileChecker(filename);


}


/*************************************...


void fileChecker (char filename[20])


{


if((fp = fopen(filename, "r")) == NULL)


{


printf("\nDo you wish to \n(a) enter filename, \n(b)create a new file, or \n(c)exit the program\n? (a/b/c) ");


option = tolower(getche());


if(option == 'a')


{


retrieverFilename();


}


else if(option == 'b')


{


printf("\nCreating a New Record File...");


fp = fopen(filename, "w+t");


sorter();


storer();


}


else if(option == 'c')


{


printf("Goodbye!");


exit(1);


}


}


while(option != 'a' %26amp;%26amp; option != 'b' %26amp;%26amp; option != 'c');


}


else


{


printf("\n\nRecord File already exists!");


do


{


printf("\nDo you wish to


menu = tolower(getche());


}


while(menu != 'a' %26amp;%26amp; menu != 'b' %26amp;%26amp; menu != 'c' %26amp;%26amp; menu != 'd');








fclose(fp);


n = m;





fp = fopen(t");


storer();


}


else if(menu == 'c)


{


retrieverFilename();


}


else


{


printf("\nGoodbye!");


exit(1);


}


}


}
Reply:Oracletutorials.info is your gateway to the best


sites on the Internet for Oracle tutorials!


http://oracletutorials.info/


No comments:

Post a Comment