void deletebooks() { /* Delete books from library on basis of book id */ system("clear"); int d, y; while(1) { system("clear"); printf("Enter the Book ID to delete:"); scanf("%d", &d); fp = fopen("Library.dat", "rb+"); rewind(fp); while(fread(&a, sizeof(a), 1, fp) == 1) { if(a.id == d) { printf("The book record is available\n"); printf("Book name is %s\n", a.name); printf("Rack No. is %d\n", a.rackno); flag = 10; } } if(flag != 10) { printf("No record is found modify the search"); mainmenu(); } if(flag == 10) { printf("Do you want to delete it?(Y/N) press 1 for YES and 2 for NO:"); scanf("%d", &y); if(y == 1) { ft = fopen("test.dat", "w+"); /* create new file test.dat copy all data remove Library.dat an then rename test.dat to Librarydat */ rewind(fp); while(fread(&a, sizeof(a), 1, fp) == 1) { if(a.id != d) { fseek(ft, 0, SEEK_CUR); fwrite(&a, sizeof(a), 1, ft); } } fclose(ft); fclose(fp); remove("Library.dat"); rename("test.dat", "Library.dat"); if(flag == 10) { printf("The record is sucessfully deleted\n"); printf("Delete another record?(Y/N) press 1 for YES and 2 for NO\n"); scanf("%d", &y); if(y == 2) mainmenu(); else deletebooks(); } } else mainmenu(); } } }
void mainmenufirst(int i) { char key; //Detect key UP and DOWN until ENTER is pressed do { key = getch(); //Get the input switch(key) { case 72 : mainmenu(--cursor); //Select upper menu break; case 80 : mainmenu(++cursor); //Select lower menu break; } } while(key!=13); switch(cursor) { case 1 : create(cursor2); break; case 2 : query(cursor3); break; case 3 : system("cls"); printf("\n\n\n\t==========================================================\n"); printf("\t| |\n"); printf("\t| ++++++++++ +++ +++ + ++++ +++ +++ ++++ |\n"); printf("\t| ++++++++++ +++ +++ +++ +++++ +++ +++ ++++ |\n"); printf("\t| ++++ +++++++++ ++ ++ +++ ++ +++ +++++++ |\n"); printf("\t| ++++ +++++++++ +++++++ +++ +++++ ++++++ |\n"); printf("\t| ++++ +++ +++ ++ ++ +++ ++++ +++ +++ |\n"); printf("\t| ++++ +++ +++ ++ ++ +++ +++ +++ ++++ |\n"); printf("\t| |\n"); printf("\t| ++ ++ ++++ +++ +++ |\n"); printf("\t| ++ ++ +++ +++ +++ +++ |\n"); printf("\t| ++ ++ +++ +++ +++ +++ |\n"); printf("\t| +++ +++ +++ +++ +++ |\n"); printf("\t| +++ +++ +++ +++ +++ |\n"); printf("\t| +++ ++++ +++++ |\n"); printf("\t| |\n"); printf("\t=========================================================="); Sleep(1000); exit(1); //Exit game } }
void mainmenufirst2(int i) { char key; //Detect key UP and DOWN until ENTER is pressed do { key = getch(); //Get the input switch(key) { case 72 : create(--cursor2); //Select upper menu break; case 80 : create(++cursor2); //Select lower menu break; } } while(key!=13); switch(cursor2) { case 1 : createDB(); break; case 2 : createTable("",""); cursor2 = 1; mainmenu(cursor2); break; case 3: deleteDB(); cursor2=7; Sleep(400); create(cursor2); cursor2=1; break; case 4: deleteTable(); create(cursor2); cursor2=1; break; case 5 : cursor2 = 1; mainmenu(cursor2); break; } }
int main() { char wel[30]= "++++ Welcome to Database ++++"; char main[30] = "++++ Main Menu ++++"; system( "color f0"); printf("\n\t"); for(i=0; i<30; i++) { printf("%c",wel[i]); if(i==3||i==24) { printf("%c",178); } Sleep(50); } Sleep(50); system("cls"); printf("\n\t"); for(i=0; i<19; i++) { printf("%c",main[i]); Sleep(50); } Sleep(300); mainmenu(cursor); getch(); }
/* this function menu for sudent*/ void student(){ char ch; printf("\n"); printf("----------------1.SEARCH-------------------------------\n"); printf("----------------2.SHOW BOOK RECORD BRANCH WISE---------\n"); printf("----------------3.CHANGE PASSWORD------------------------\n"); printf("----------------4.MAINMENU--------------------------------\n"); scanf(" %c",&ch); switch(ch){ case '1': search(); break; case '2': show(); break; case '3': changepass(); break; case '4': mainmenu(); break; default : printf("---------invalid input----------\n"); student(); break; } }
void viewbooks(void) { /* View all the books present in library */ int i = 0, j, y; system("clear"); printf("*********************************Book List*****************************\n"); j = 4; fp = fopen("Library.dat", "rb+"); while(fread(&a, sizeof(a), 1, fp) == 1) { printf("BRANCH : %s\n", a.cat); printf("BOOK ID : %d\n", a.id); printf("BOOK NAME : %s\n", a.name); printf("AUTHOR : %s\n", a.Author); printf("QUANTY : %d\n", a.quantity); printf("PRICE : %.2f\n", a.Price); printf("RACK NO : %d\n", a.rackno); printf("\n\n"); j++; i = i + a.quantity; } printf("Total Books = %d\n",i); printf("Press 1 to go main menu :"); scanf("%d", &y); if(y == 1) mainmenu(); }
int main() { char ch; welcomescreen(); printrule(); do { switch(mainmenu()) { case 0 :loadgame(); break; case 1: controls(); break; case 2: ; break; } printf("\nDo you want to play now ? ( Y OR N)\n"); scanf("%c",&ch); ch = tolower(ch); } while(ch =='y'); clrscr(); printf("Your score has been saved to Snake.txt\n"); FILE *fp; fp = fopen("Snake.txt", "a"); fprintf(fp,"Player score : %d\n", globscore); printf("\n\nThanks for playing\n"); fclose(fp); return 0 ; }
int main() { hyplnk = 0; while(hyplnk != 49) { mainmenu(); switch (hyplnk) { case 49: break; case 50: clrscr(); info();break; case 51: clrscr(); score_record(); } clrscr(); } gotoxy(2, 20); printf("Enter the player name : "); scanf("%s", &name); printf("\t\tPress any key to start"); initiallize(); play(scr, life); getch(); return 0; }
void studentmenu() { stuview(); printf("Enter any key to return to main menu"); getch(); mainmenu(); }
void calendermenu() { calender(); textcolor(15); printf("Enter any key to return to main menu"); getch(); mainmenu(); }
int main() { resetgame(); //prints the Main Menu mainmenu(cursor); char key; //Detect key UP and DOWN until ENTER is pressed do { key = getch(); //Get the input switch(key) { case 72 : mainmenu(--cursor); //Select upper menu break; case 80 : mainmenu(++cursor); //Select lower menu break; } } while(key!=13); //Launch a game or screen depending on the menu selected switch(cursor) { case 1 : singlegame(); break; case 2 : multigame(); break; case 3 : battlegame(); break; case 4 : howtoplay(); break; case 5 : credit(); break; case 6 : exit(1); //Exit game } }
void mainmenu(int x) { system("cls"); switch(x) { case 1 : printf("\n\t++++ Main Menu ++++"); printf("\n\t[*] Create / Modify"); printf("\n\t[ ] Query"); printf("\n\t[ ] Exit"); printf("\n\tUse the arrow keys to select the menu and ENTER to confirm."); //printf("%d",cursor); break; case 2 : printf("\n\t++++ Main Menu ++++"); printf("\n\t[ ] Create / Modify"); printf("\n\t[*] Query"); printf("\n\t[ ] Exit"); printf("\n\tUse the arrow keys to select the menu and ENTER to confirm."); break; case 3 : printf("\n\t++++ Main Menu ++++"); printf("\n\t[ ] Create / Modify"); printf("\n\t[ ] Query"); printf("\n\t[*] Exit"); printf("\n\tUse the arrow keys to select the menu and ENTER to confirm."); break; default : if(x > 3) { cursor = x = 1; mainmenu(cursor); } else if(x < 1) { cursor = x = 3; mainmenu(cursor); } } mainmenufirst(cursor); }
int main() { init(); // initialize your variables while (!g_quitGame) // run this loop until user wants to quit { mainmenu(); // runs the menu screen } shutdown(); // do clean up, if any. free memory. return 0; }
void mainmenu() { /* Call every function handle from Administrator */ int i,r; system("clear"); printf(" \n"); printf("************************ Libary Management ************************\n"); printf(" Main Menu\n\n"); printf("1. Add Books\n"); printf("2. Delete books\n"); printf("3. View Book list\n"); printf("4. Edit Book's Record\n"); printf("5. Search Books\n"); printf("6. Issue Books\n"); printf("7. Back to Student Section\n"); printf("8. Close Application\n"); printf("Enter your choice:\n"); scanf("%d", &r); switch(r) { case 1: addbooks(); break; case 2: deletebooks(); break; case 3: viewbooks(); break; case 4: editbooks(); break; case 5: searchbooks(); break; case 6: issuebooks(); break; case 7: start(); break; case 8: { system("clear"); exit(0); } default: printf("\aYou entered wrong chioce\n"); mainmenu(); } }
void addbooks() { /* Add new book to library. Details of books and on which shelf it is*/ int y; system("clear"); int i; printf("SELECT CATEGOIES\n"); printf("1.Computer\n"); printf("2.IT\n"); printf("3.Electrical\n"); printf("4.Civil\n"); printf("5.Mechanical\n"); printf("6.Architecture\n"); printf("7.Back to main menu\n"); printf("Enter your choice:"); scanf("%d",&s); if(s == 8) { mainmenu() ; } system("clear"); fp = fopen("Library.dat", "ab+"); if(getdata() == 1) { a.cat = branch[s-1]; fseek(fp, 0, SEEK_END); fwrite(&a, sizeof(a), 1, fp); fclose(fp); printf("The record is sucessfully saved\n"); printf("Save any more?(Y / N) press 1 for YES and 2 for NO:"); scanf("%d", &y); if(y == 2) { mainmenu(); } else { system("clear"); addbooks(); } } }
void display () { // Function that clears the window. If you don't want to clear the view window, don't call glClear function. make it as a comment statement. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //LoadFPS(10000); // printf("flagpalyer=%d\n",flagplayer); //mode Select korar jonno.......... if(flagmode==0) mainmenu(); glutSwapBuffers(); }
int start() { system("clear"); int log; printf("************************Libary Management************************\n"); printf("1. Student Section\n"); printf("2. Administrator\n"); scanf("%d", &log); switch(log) { case 1: login(); break; case 2: mainmenu(); break; } return 0; }
void editbooks() { /* Edit details of books like shelf, no. of copies, etc.*/ system("clear"); int c = 0, y, d, e; printf(" Edit Books\n"); while(1) { system("clear"); printf("Enter Book Id to be edited:"); scanf("%d", &d); fp = fopen("Library.dat", "rb+"); while(fread(&a, sizeof(a), 1, fp) == 1) { if(checkid(d) == 0) { printf("The book is availble\n"); printf("The Book ID:"); scanf("%d", &a.id); printf("Enter new name:"); scanf("%s", a.name); printf("Enter new Author:"); scanf("%s" ,a.Author); printf("Enter new quantity:"); scanf("%d", &a.quantity); printf("Enter new price:"); scanf("%f", &a.Price); printf("Enter new rackno:"); scanf("%d", &a.rackno); printf("The record is modified\n"); fseek(fp, ftell(fp) - sizeof(a), 0); fwrite(&a, sizeof(a), 1, fp); fclose(fp); c = 1; } if(c == 0) { printf("No record found\n"); } } printf("Modify another Record?(Y/N) pres 1 for YES and 2 for NO"); scanf("%d", &y); if(y == 2) { mainmenu(); } else { system("clear"); editbooks(); } } }
// Display Function......... void display(void) { glClear(GL_COLOR_BUFFER_BIT); glBegin( GL_POINTS ); int i,j; for(i=0;i<=100;i++){ for(j=0;j<=100;j++){ //glColor3f(4.65,4.56,4.3); //glVertex2d( i,j); } } glEnd(); mainmenu(); glFlush(); glutSwapBuffers(); return ; //glTranslatef(-100,-100,0); glScalef(35,35,1); // for debug ..................... draw_circle(circle(s,.03)); draw_circle(circle(d,.03)); for(i=1;i<=n;i++){ draw_rect(rects[i]); } // .......................... }
void add(){ fp=fopen("emp1.txt","ab+"); fseek(fp,0,SEEK_END); another = 'y'; while(another == 'y') { printf("Enter employee id:\n"); scanf("%d",&t); if(already(t) == 0){ printf("\nThe employee id already exists\n\n"); mainmenu(); } e.emp_id=t; printf("Enter name:\n"); scanf("%s",e.name); printf("Enter age:\n"); scanf("%d", &e.age); printf("Enter address:\n"); scanf("%s",e.address); printf("Enter basic salary:\n"); scanf("%f", &e.salary); printf("Enter year of experience:\n"); scanf("%d",&e.year_of_experience); printf("Enter Employee post:\n"); scanf("%s",e.post); /*printf("Enter Date of birth:\n"); scanf("%d",&e.DOB); printf("Enter Blood Group:\n"); scanf("%s",e.blood_group);*/ fwrite(&e,recsize,1,fp); printf("You can also perform another operation:\n "); scanf("%c",&another); } }
/*this function show menu for admin*/ void admi(){ char ch; printf("\n"); printf(" --------1.SHOW BOOK RECORD------ \n"); printf(" --------2.ADD BOOKS------------- \n"); printf(" --------3.CHANGE PASSWAORD------ \n"); printf(" ------- 4.REMOVE BOOKS---------- \n"); printf(" ------- 5.RETURN BOOK----------- \n"); printf(" ------- 6.STUDENT INFORMATION--- \n"); printf(" ------- 7.ISSUE BOOK RECORD----- \n"); printf(" ------- 8.MAINMENU-------------- \n"); scanf(" %c",&ch); switch(ch){ case '1': showrcrd(); break; case '2': addbooks(); break; case '3': achangepass(); break; case '4': rmbook(); break; case '5': retur(); break; case '6': sti(); break; case '7': just1(); break; case '8': mainmenu(); break; default : printf("---------INVALID INPUT----------\n"); admi(); break; } }
void createDB() { system("cls"); int i,tableN; char DBName[100]; char DBName2[100]; char path[100]=".\\db"; char dbn[200] = ".\\db\\"; printf("\n\tDatabase Name: "); gets(DBName); //printf("\n\tHow many tables do you want? : "); //scanf("%d",&tableN); strcat(dbn,DBName); if((fpt = fopen(strcat(dbn,".txt"),"w")) == NULL) { perror("\n\tError creating new file, please try again or read the manual."); system("PAUSE"); exit(1); } else { tableN = 1; fprintf(fpt,"TNUM %d\n",tableN); if(tableN > 0) { fclose(fpt); //printf("kkkk"); //for(i = 0; i < tableN; i++) //{ createTable("CREATED",DBName); //} } else { fclose(fpt); printf("\nDatabase Created"); system("PAUSE"); } } i=1; mainmenu(i); }
/*------------------------------------------------------------------------*/ int main() { int ok; read_config(); _set_screen_lines(25); _setcursortype(_NOCURSOR); Screen("Joystick configuration utility for Atari 800 emulator",BACKGROUND+TITLE); ok=mainmenu(); window(1,1,80,25); textattr(0xf); clrscr(); _setcursortype(_NORMALCURSOR); if (ok) save_config(); return 0; }
char *decode_string(unsigned char *buffer,unsigned int code) { int i; i=0; while (code > 255) { *buffer++ = append_character[code]; code=prefix_code[code]; if (i++>=4094) { printf("Fatal error during code expansion.\n"); getch(); mainmenu(-2); } } *buffer=code; return(buffer); }
int main(int argc, char *argv[]) { srand(time(NULL)); char **gamepaths; int i; nh_bool init_ok; umask(0777 & ~FCMASK); /* this can change argc and *argv, so must come first */ initialize_uncursed(&argc, argv); process_args(argc, argv); /* grab -U, -H, -k, --help early */ init_options(); gamepaths = init_game_paths(argv[0]); nh_lib_init(&curses_windowprocs, (const char * const*)gamepaths); init_curses_ui(gamepaths[DATAPREFIX]); init_ok = read_nh_config(); for (i = 0; i < PREFIX_COUNT; i++) free(gamepaths[i]); free(gamepaths); process_args(argc, argv); /* other command line options */ init_displaychars(); if (init_ok) mainmenu(); else curses_msgwin("Could not initialize game options!", krc_notification); exit_curses_ui(); nh_lib_exit(); free_displaychars(); exit(EXIT_SUCCESS); /*NOTREACHED*/ return 0; }
void mainmenufirst3(int t) { char key; //Detect key UP and DOWN until ENTER is pressed do { key = getch(); //Get the input switch(key) { case 72 : query(--cursor3); //Select upper menu break; case 80 : query(++cursor3); //Select lower menu break; } } while(key!=13); switch(cursor3) { case 1 : system("cls"); readDB("SELECT"); system("PAUSE"); query(cursor3); break; case 2 : system("cls"); readDB("ALL"); system("PAUSE"); query(cursor3); break; case 3 : cursor3 = 1; mainmenu(cursor3); } }
void startmenu(menu *mp, char *mtitle) { initscr(); incurses = TRUE; initcolor(); wtitl = subwin(stdscr, th, bw, 0, 0); wmain = subwin(stdscr, mh, bw, th, 0); wbody = subwin(stdscr, bh, bw, th + mh, 0); wstat = subwin(stdscr, sh, bw, th + mh + bh, 0); colorbox(wtitl, TITLECOLOR, 0); colorbox(wmain, MAINMENUCOLOR, 0); colorbox(wbody, BODYCOLOR, 0); colorbox(wstat, STATUSCOLOR, 0); if (mtitle) titlemsg(mtitle); cbreak(); /* direct input (no newline required)... */ noecho(); /* ... without echoing */ curs_set(0); /* hide cursor (if possible) */ nodelay(wbody, TRUE); /* don't wait for input... */ halfdelay(10); /* ...well, no more than a second, anyway */ keypad(wbody, TRUE); /* enable cursor keys */ scrollok(wbody, TRUE); /* enable scrolling in main window */ leaveok(stdscr, TRUE); leaveok(wtitl, TRUE); leaveok(wmain, TRUE); leaveok(wstat, TRUE); mainmenu(mp); cleanup(); }
int getdata() { /* accept data to add book */ int t; printf("Enter the Information Below\n"); printf("Category:"); printf("%s",branch[s-1]); printf("\nBook ID:\t"); scanf("%d",&t); if(checkid(t) == 0) { printf("The book id checkid exists\t"); mainmenu(); } a.id = t; printf("\nBook Name:"); scanf("%s", a.name); printf("\nAuthor:"); scanf("%s", a.Author); printf("\nQuantity:"); scanf("%d", &a.quantity); printf("\nPrice:"); scanf("%f", &a.Price); printf("\nRack No:"); scanf("%d", &a.rackno); return 1; }
void addentry(){ int i, s; /*Setting border color */ init_pair(2,COLOR_MAGENTA,COLOR_BLACK); attron(COLOR_PAIR(2)); border(0,0,0,0, 0,0,0,0); refresh(); attroff(COLOR_PAIR(2)); refresh(); int fict, sh, ref, nonfict; FILE *fp; Book book; char option = 'y'; clear(); refresh(); while(option == 'y' || option == 'Y') { printgen(); scanw("%d",&s); switch(s) { case FICTION : printfiction(); scanw("%d",&fict); fp=fopen("Fiction.dat","ab+"); if(getinfo(&book)){ book.cat = categories[s - 1]; book.subcat = fiction[fict - 1]; fseek(fp,0,SEEK_END); fwrite(&book,sizeof(book),1,fp); fclose(fp); } break; case NONFICTION : fp=fopen("Nonfiction.dat","ab+"); if(getinfo(&book) == 1){ book.cat = categories[s-1]; book.subcat = categories[s-1]; fseek(fp,0,SEEK_END); fwrite(&book,sizeof(book),1,fp); fclose(fp); } break; case REFERENCE : printref(); scanw("%d",&ref); fp=fopen("Reference.dat","ab+"); if(getinfo(&book) == 1){ book.cat = categories[s-1]; book.subcat = refer[ref - 1]; fseek(fp,0,SEEK_END); fwrite(&book,sizeof(book),1,fp); fclose(fp); } break; case SELFHELP : printselfhelp(); scanw("%d",&sh); fp=fopen("Selfhelp.dat","ab+"); if(getinfo(&book) == 1){ book.cat,categories[s-1]; book.subcat = selfhelp[sh - 1]; fseek(fp,0,SEEK_END); fwrite(&book,sizeof(book),1,fp); fclose(fp); } break; case MENU : mainmenu(); return; break; default : printw("\n ----- Wrong option. Please select again -----\n"); addentry(); return; } mvaddstr(10,16,"The record is sucessfully saved"); mvaddstr(11,16,"Add more ? (y/n) "); option = getch(); } mvaddstr(12,16,"Press Enter to go to main menu"); getch(); mainmenu(); refresh(); return; }
void main() { fstream ifile,ofile; settings u,t; char ch,user1[20],pass1[20]; int a=1,b,c,d,e; again: int i = mainmenu(); switch(i) { case 1: { newuser: /* adding a user */ clrscr(); ofile.open("settings.dat",ios::binary|ios::out|ios::app); u.getuser(); if(u.usercheck()==1){cout<<"\n Sorry User already exists!returning to main menu...";ofile.close();getch();goto newuser;} ofile.write((char*)&u,sizeof(u)); ofile.close(); cout<<"\n User added.press m to return to main menu "; cin>>ch; if(ch == 'm') goto again; break; } case 2: { /* searching for user */ clrscr(); gotoxy(30,15);cout<<" Enter username:"******"settings.dat",ios::binary | ios::in); while(!ifile.eof()) { ifile.read((char*)&u,sizeof(u)); if(strcmp(u.username,user1) == 0) {a=0;break;}} if(a==0) {gotoxy(30,17); cout<<user1;} else {gotoxy(30,17);cout<<"\n not found";} ifile.close(); cout<<"\n Press m to return to main menu"; cin>>ch; if(ch=='m') goto again; } deluser: case 3: { /* deleting user */ clrscr(); gotoxy(20,13);cout<<"\n Entet details of the user to delete: "; t.getuser(); if(t.usercheck()==0){cout<<"\n user not found"; getch();goto again;} ifstream ifi("settings.dat",ios::binary); ofstream ofi("newsettings.dat",ios::binary); while(!ifi.eof()) { ifi.read((char*)&u,sizeof(u)); if(strcmp(t.username,u.username)!=0) ofi.write((char*)&u,sizeof(u)); } ifi.close(); ofi.close(); remove("settings.dat"); rename("newsettings.dat","settings.dat"); cout<<"\n user deleted.. press m to return to main menu"; cin>>ch; if(ch=='m') goto again; break; } case 4: { clrscr(); gotoxy(30,10);cout<<" the existing users :"; ifstream file("settings.dat",ios::binary); if(file) { gotoxy(30,12);cout<<"username password"; while(file.read((char*)&u,sizeof(u))) { gotoxy(30,16+i);cout<<u.username<<"\t\t"<<u.password; i+=2; } file.close(); } cout<<"\n Press m to return to main menu"; cin>>ch; if(ch=='m') goto again; } case 5: {ofile.open("newsettings.dat",ios::binary|ios::in); ofile.close(); remove("settings.dat"); rename("newsettings.dat","settings.dat"); goto again; } } }