DevioLab CRYPTO TRADING AUTOMATION
LIVE
AUTOMATED CRYPTO TRADING • BINANCE
Автоматизуйте свій криптопортфель
Торгові боти DevioLab аналізують крипторинок, автоматично відкривають і закривають позиції та керують вашим портфелем на Binance 24/7.
CRYPTO 80 Bots
BINANCE Spot Trading
TRADING 24 / 7
Спробувати DevioLab
deviolab.com

Послідовний метод доступу до файлів на зовнішніх запам’ятовуючих пристроях

Інформація про навчальний заклад

ВУЗ:
Національний університет Львівська політехніка
Інститут:
Не вказано
Факультет:
Не вказано
Кафедра:
Кафедра САПР

Інформація про роботу

Рік:
2015
Тип роботи:
Звіт
Предмет:
Інші

Частина тексту файла (без зображень, графіків і формул):

МІНІСТЕРСТВО ОСВІТИ ТА НАУКИ УКРАЇНИ НАЦІОНАЛЬНИЙ УНІВЕРСИТЕТ “ЛЬВІВСЬКА ПОЛІТЕХНІКА”  Кафедра САПР Звіт до лабораторної роботи №1 на тему: «Послідовний метод доступу до файлів на зовнішніх запам’ятовуючих пристроях» Текст програми: #include <stdio.h> #include <string.h> #include <conio.h> #include <stdlib.h> #define ROWS 0 #define MAXNAME 40 #define MAXPLATFORM 20 #define MAXDEVELOPER 30 #define MAXPUBLISHER 30 #define MAXRELEASEDATE 10 #define MAXGENRE 20 #define MAXHOMEPAGE 20 #define MAXTRANSMITTER 10 #define MAXGRAPHICS 10 char nameOfDatabase[20]; FILE *f; FILE *fTemp; struct game { int ID; char name[MAXNAME]; char developer[MAXDEVELOPER]; char publisher[MAXPUBLISHER]; char platform[MAXPLATFORM]; char genre[MAXGENRE]; char homepage[MAXHOMEPAGE]; char releaseDate[MAXRELEASEDATE]; int age; char transmitter[MAXTRANSMITTER]; int gameRate; char graphics[MAXGRAPHICS]; }; struct gameM2Edit { int ID; char name[MAXNAME]; char developer[MAXDEVELOPER]; char publisher[MAXPUBLISHER]; char platform[MAXPLATFORM]; char genre[MAXGENRE]; char homepage[MAXHOMEPAGE]; char releaseDate[MAXRELEASEDATE]; int age; char transmitter[MAXTRANSMITTER]; int gameRate; char graphics[MAXGRAPHICS]; int what; int whatEdit; }; void addElementInDatabase(struct game addGame); void deleteElementInDatabase(int); void edit(int,int,struct game addGame); void revision(); void search(int,struct game addGame); int main(void) { int methodBool=0; //Змінна для перевірки вибору методу. int back=1; //Змінна для перевірки чи потрібно виводити головне меню. int method; //method - змінна для збереження вибору методу. int menuItem,menuExit=7,menuExit2=5; // menuItem - змінна для зберігання вибору пункту головного меню, menuExit - змінна для перевірки виходу з програми. int menuItemP; //Змінна для зберігання вибору підменю кожного меню. int yes_no; //Змінна для перевірки вибору меню кожного підменю. int backGo; //Змінна для перевірки нажато "0" для виходу в гол. меню. int yes_noGameRate=0; //Змінна для перевірки вибору оцінки гри. int ID; //ID - елемента, який потрібно видалити або редагувати. char nameOfFile[20]; //Змінна для збереження назви нової бази даних. FILE *fileDatabase; //Мітка для файлу ств. бази даних. struct game workGame; system("cls"); //***Вибір методу роботи з файлом бази даних. printf("Choose the method of work with the database:\n\n"); printf("1. Sequential access to the file.\n"); printf("2. Access to the files with the batch-processing of information.\n\n"); printf("Choose and enter one of menu items: "); scanf("%d",&method); //**Перевірка вибраний пункт меню чи ні. do { if (method==1 || method==2) { methodBool=1; } else { printf("You have not chosen any menu item. Please enter once again: "); scanf("%d",&method); } } while (methodBool != 1); //**Кінець - Перевірка вибраний пункт меню чи ні. //***Кінець - Вибір методу роботи з файлом бази даних. //***Перший метод. if (method==1) { //***Перевірка виходу з програми. do { //***Перевірка виводу головного меню. if (back==1) { system("cls"); printf(" You chosen a method 1.\n"); printf(" Menu:\n1. Creation a database.\n2. Insert the element in a database (ID).\n3. Delete of element. \n4. Editing is after the key field. \n5. Revision bases given. \n6. Search in the database. \n7. Close a programm.\n"); printf("Choose and enter one of menu items: "); scanf("%d",&menuItem); } //***Кінець - Перевірка виводу головного меню. //**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ВИБІР ПУНКТУ '1'.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ if (menuItem==1) { menuItemP=0; printf("\n Do you want to create a new database? The old database will be deleted.\n"); printf("1. Yes\n2. No\n"); printf("Choose and enter one of menu items: "); scanf("%d",&menuItemP); //**Перевірка вибраний пункт підменю головного меню чи ні. if (menuItemP==1 || menuItemP==2) { yes_no=1; } else { yes_no=0; } //*Перевірка чи потрібно виконувати цикл, якщо не вибраний пункт підменю. while (yes_no!=1) { printf("You have not chosen any menu item. Please enter once again: "); scanf("%d",&menuItemP); if (menuItemP==1 || menuItemP==2) { yes_no=1; } } //*Кінець - Перевірка чи потрібно виконувати цикл, якщо не вибраний пункт підменю. //**Кінець - Перевірка вибраний пункт підменю головного меню чи ні. if (menuItemP==1) { //Потрібно створювати базу даних??? printf("\nEnter name of the file (MAX-20): "); scanf("%s",&nameOfFile); //Введення назви файлу бази даних. strcat(nameOfFile,".txt"); //Додавання розширення .txt до імені. //**Перевірка чи створений файл бази даних чи ні та виведення результату. if ((fileDatabase=fopen(nameOfFile,"w")) == NULL) { printf("\nAn error is at creation of file. %s.",nameOfFile); } else { printf("\nA file is successfully creation. Name of file %s.",nameOfFile); } //**Кінець - Перевірка чи створений файл бази даних чи ні та виведення результату. //*Перевірка чи закритий файл бази даних чи ні та виведення результату. if (fclose(fileDatabase) != 0) { printf("\nAn error is at closing of file %s.",nameOfFile); } else { printf("\nA file is successfully closed."); } //*Кінець - Перевірка чи закритий файл бази даних чи ні та виведення результату. } //**Повернення в головне меню. printf("\nEnter '0' for returning in a main menu: "); scanf("%d",&backGo); while (backGo!=0) { printf("You have not enter '0'. Please enter once again: "); scanf("%d",&backGo); } //**Кінець - Повернення в головне меню. back=1; //Вивід головного меню дозволений. } //**Кінець - Вибір пункту 1. //**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ВИБІР ПУНКТУ '2'.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@. else if (menuItem==2) { menuItemP=0; printf("\n Do you want to insert a new element in a database?\n"); printf("1. Yes\n2. No\n"); printf("Choose and enter one of menu items: "); scanf("%d",&menuItemP); //**Перевірка вибраний пункт підменю головного меню чи ні. if (menuItemP==1 || menuItemP==2) { yes_no=1; } else { yes_no=0; } //*Перевірка чи потрібно виконувати цикл, якщо не вибраний пункт підменю. while (yes_no!=1) { printf("You have not chosen any menu item. Please enter once again: "); scanf("%d",&menuItemP); if (menuItemP==1 || menuItemP==2) { yes_no=1; } } //*Кінець - Перевірка чи потрібно виконувати цикл, якщо не вибраний пункт підменю. //**Кінець - Перевірка вибраний пункт підменю головного меню чи ні. if (menuItemP==1) { printf("\nEnter the name database which you want to open (MAX-20): "); scanf("%s",&nameOfDatabase); //Введення назви файлу бази даних. strcat(nameOfDatabase,".txt"); //Додавання розширення .txt до імені. //***Введення даних. printf("\nEnter next information for a record in a database."); printf("\n1. Enter ID of the game: "); scanf("%d",&workGame.ID); printf("2. Enter platform (MAX-10): "); scanf("%s",&workGame.platform); printf("3. Enter name of the game (MAX-40): "); scanf("%s",&workGame.name); printf("4. Enter developer (MAX-30): "); scanf("%s",&workGame.developer); printf("5. Enter publisher (MAX-30): "); scanf("%s",&workGame.publisher); printf("6. Enter release date (MAX-10): "); scanf("%s",&workGame.releaseDate); printf("7. Enter genre (MAX-20): "); scanf("%s",&workGame.genre); printf("8. Enter homepage (MAX-20): "); scanf("%s",&workGame.homepage); printf("9. Enter transmitter (MAX-10): "); scanf("%s",&workGame.transmitter); printf("10. Enter graphics (MAX-10): "); scanf("%s",&workGame.graphics); printf("11. Enter age (MAX-3): "); scanf("%d",&workGame.age); printf("12. Enter game rate (1,2,3,4 or 5): "); scanf("%d",&workGame.gameRate); if (workGame.gameRate==1 || workGame.gameRate==2 || workGame.gameRate==3 || workGame.gameRate==4 || workGame.gameRate== 5) { yes_noGameRate=1; } while (yes_noGameRate!=1) { printf("You have not enter 1, 2, 3, 4 or 5. Please enter once again: "); scanf("%d",&workGame.gameRate); if (workGame.gameRate==1 || workGame.gameRate==2 || workGame.gameRate==3 || workGame.gameRate==4 || workGame.gameRate== 5) { yes_noGameRate=1; } } //***Кінець - Введення даних. //**Вивід даних. printf("\n----------------------------------"); printf("\nYour dates:\n"); printf("\nID: %d\nPlatform: %s\nName: %s\nDeveloper: %s\nPublisher: %s\nRelease date: %s\nGenre: %s\nHomepage: %s\nTransmitter: %s\nGraphics: %s\nAge: %d\nGame rate: %d\n",workGame.ID,workGame.platform,workGame.name,workGame.developer,workGame.publisher,workGame.releaseDate,workGame.genre,workGame.homepage,workGame.transmitter,workGame.graphics,workGame.age,workGame.gameRate); printf("\n----------------------------------\n"); //**Кінець - Вивід даних. addElementInDatabase(workGame); } //**Повернення в головне меню. printf("\nEnter '0' for returning in a main menu: "); scanf("%d",&backGo); while (backGo!=0) { printf("You have not enter '0'. Please enter once again: "); scanf("%d",&backGo); } //**Кінець - Повернення в головне меню. back=1; } //**Кінець - Вибір пункту 2. //**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ВИБІР ПУНКТУ '3'.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@. else if (menuItem==3) { menuItemP=0; printf("\n Do you want to delete an element in a database?\n"); printf("1. Yes\n2. No\n"); printf("Choose and enter one of menu items: "); scanf("%d",&menuItemP); //**Перевірка вибраний пункт підменю головного меню чи ні. if (menuItemP==1 || menuItemP==2) { yes_no=1; } else { yes_no=0; } //*Перевірка чи потрібно виконувати цикл, якщо не вибраний пункт підменю. while (yes_no!=1) { printf("You have not chosen any menu item. Please enter once again: "); scanf("%d",&menuItemP); if (menuItemP==1 || menuItemP==2) { yes_no=1; } } //*Кінець - Перевірка чи потрібно виконувати цикл, якщо не вибраний пункт підменю. //**Кінець - Перевірка вибраний пункт підменю головного меню чи ні. if (menuItemP==1) { printf("\nEnter the name database which you want to open (MAX-20): "); scanf("%s",&nameOfDatabase); //Введення назви файлу бази даних. strcat(nameOfDatabase,".txt"); //Додавання розширення .txt до імені. //***Введення даних. printf("\nEnter ID of element to delete: "); scanf("%d",&ID); deleteElementInDatabase(ID); } //**Повернення в головне меню. printf("\nEnter '0' for returning in a main menu: "); scanf("%d",&backGo); while (backGo!=0) { printf("You have not enter '0'. Please enter once again: "); scanf("%d",&backGo); } //**Кінець - Повернення в головне меню. back=1; } //**Кінець - Вибір пункту 3. //**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ВИБІР ПУНКТУ '4'.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@. else if (menuItem==4) { menuItemP=0; printf("\n Do you want to edit an element in a database?\n"); printf("1. Yes\n2. No\n"); printf("Choose and enter one of menu items: "); scanf("%d",&menuItemP); //**Перевірка вибраний пункт підменю головного меню чи ні. if (menuItemP==1 || menuItemP==2) { yes_no=1; } else { yes_no=0; } //*Перевірка чи потрібно виконувати цикл, якщо не вибраний пункт підменю. while (yes_no!=1) { printf("You have not chosen any menu item. Please enter once again: "); scanf("%d",&menuItemP); if (menuItemP==1 || menuItemP==2) { yes_no=1; } } //*Кінець - Перевірка чи потрібно виконувати цикл, якщо не вибраний пункт підменю. //**Кінець - Перевірка вибраний пункт підменю головного меню чи ні. if (menuItemP==1) { printf("\nEnter the name database which you want to open (MAX-20): "); scanf("%s",&nameOfDatabase); //Введення назви файлу бази даних. strcat(nameOfDatabase,".txt"); //Додавання розширення .txt до імені. //***Введення даних. printf("\nEnter ID of element to edit: "); scanf("%d",&ID); yes_no=0; int menuItemEdit; //Змінна для збереження вибору меню. int elemEdit=0; //Який елемент маэ бути відредагований. while (yes_no!=1) { system("cls"); printf("\nWhat you want to edit: "); printf("\n1. Platform\n2. Name\n3. Developer\n4. Publisher\n5. Release date\n6. Genre\n7. Homepage\n8. Transmitter\n9. Graphics\n10. Age\n11. Game rate\n"); printf("Choose and enter one of menu items: "); scanf("%d",&menuItemEdit); if (menuItemEdit==1) { printf("Enter platform (MAX-10): "); scanf("%s",&workGame.platform); elemEdit=1; edit(ID,elemEdit,workGame); } else if (menuItemEdit==2) { printf("Enter name (MAX-40): "); scanf("%s",&workGame.name); elemEdit=2; edit(ID,elemEdit,workGame); } else if (menuItemEdit==3) { printf("Enter Developer (MAX-30): "); scanf("%s",&workGame.developer); elemEdit=3; edit(ID,elemEdit,workGame); } else if (menuItemEdit==4) { printf("Enter Publisher (MAX-30): "); scanf("%s",&workGame.publisher); elemEdit=4; edit(ID,elemEdit,workGame); } else if (menuItemEdit==5) { printf("Enter Release date (MAX-10): "); scanf("%s",&workGame.releaseDate); elemEdit=5; edit(ID,elemEdit,workGame); } else if (menuItemEdit==6) { printf("Enter Genre (MAX-20): "); scanf("%s",&workGame.genre); elemEdit=6; edit(ID,elemEdit,workGame); } else if (menuItemEdit==7) { printf("Enter Homepage (MAX-20): "); scanf("%s",&workGame.homepage); elemEdit=7; edit(ID,elemEdit,workGame); } else if (menuItemEdit==8) { printf("Enter Transmitter (MAX-10): "); scanf("%s",&workGame.transmitter); elemEdit=8; edit(ID,elemEdit,workGame); } else if (menuItemEdit==9) { printf("Enter Graphics (MAX-10): "); scanf("%s",&workGame.graphics); elemEdit=9; edit(ID,elemEdit,workGame); } else if (menuItemEdit==10) { printf("Enter Age: "); scanf("%d",&workGame.age); elemEdit=10; edit(ID,elemEdit,workGame); } else if (menuItemEdit==11) { printf("Enter Game Rate: "); scanf("%d",&workGame.gameRate); elemEdit=11; edit(ID,elemEdit,workGame); } yes_no=1; } } //**Повернення в головне меню. printf("\nEnter '0' for returning in a main menu: "); scanf("%d",&backGo); while (backGo!=0) { printf("You have not enter '0'. Please enter once again: "); scanf("%d",&backGo); } //**Кінець - Повернення в головне меню. back=1; } //**Кінець - Вибір пункту 4. //**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ВИБІР ПУНКТУ '5'.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@. else if (menuItem==5) { menuItemP=0; printf("\n Do you want to revision a database?\n"); printf("1. Yes\n2. No\n"); printf("Choose and enter one of menu items: "); scanf("%d",&menuItemP); //**Перевірка вибраний пункт підменю головного меню чи ні. if (menuItemP==1 || menuItemP==2) { yes_no=1; } else { yes_no=0; } //*Перевірка чи потрібно виконувати цикл, якщо не вибраний пункт підменю. while (yes_no!=1) { printf("You have not chosen any menu item. Please enter once again: "); scanf("%d",&menuItemP); if (menuItemP==1 || menuItemP==2) { yes_no=1; } } //*Кінець - Перевірка чи потрібно виконувати цикл, якщо не вибраний пункт підменю. //**Кінець - Перевірка вибраний пункт підменю головного меню чи ні. if (menuItemP==1) { printf("\nEnter the name database which you want to open (MAX-20): "); scanf("%s",&nameOfDatabase); //Введення назви файлу бази даних. strcat(nameOfDatabase,".txt"); //Додавання розширення .txt до імені. //***Введення даних. revision(); } //**Повернення в головне меню. printf("\nEnter '0' for returning in a main menu: "); scanf("%d",&backGo); while (backGo!=0) { printf("You have not enter '0'. Please enter once again: "); scanf("%d",&backGo); } //**Кінець - Повернення в головне меню. back=1; } //**Кінець - Вибір пункту 5. //**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ВИБІР ПУНКТУ '6'.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@. else if (menuItem==6) { menuItemP=0; printf("\n Do you want to search in database?\n"); printf("1. Yes\n2. No\n"); printf("Choose and enter one of menu items: "); scanf("%d",&menuItemP); //**Перевірка вибраний пункт підменю головного меню чи ні. if (menuItemP==1 || menuItemP==2) { yes_no=1; } else { yes_no=0; } //*Перевірка чи потрібно виконувати цикл, якщо не вибраний пункт підменю. while (yes_no!=1) { printf("You have not chosen any menu item. Please enter once again: "); scanf("%d",&menuItemP); if (menuItemP==1 || menuItemP==2) { yes_no=1; } } //*Кінець - Перевірка чи потрібно виконувати цикл, якщо не вибраний пункт підменю. //**Кінець - Перевірка вибраний пункт підменю головного меню чи ні. if (menuItemP==1) { printf("\nEnter the name database which you want to open (MAX-20): "); scanf("%s",&nameOfDatabase); //Введення назви файлу бази даних. strcat(nameOfDatabase,".txt"); //Додавання розширення .txt до імені. //***Введення даних. yes_no=0; int menuItemSearch; //Змінна для збереження вибору меню. int elemSearch=0; //Який елемент маэ бути відредагований. while (yes_no!=1) { system("cls"); printf("\nWhat you want to edit: "); printf("\n1. Platform\n2. Name\n3. Developer\n4. Publisher\n5. Release date\n6. Genre\n7. Homepage\n8. Transmitter\n9. Graphics\n10. Age\n11. Game rate\n"); printf("Choose and enter one of menu items: "); scanf("%d",&menuItemSearch); if (menuItemSearch==1) { printf("Enter platform (MAX-10): "); scanf("%s",&workGame.platform); elemSearch=1; search(elemSearch,workGame); yes_no=1; } else if (menuItemSearch==2) { printf("Enter name (MAX-40): "); scanf("%s",&workGame.name); elemSearch=2; search(elemSearch,workGame); yes_no=1; } else if (menuItemSearch==3) { printf("Enter Developer (MAX-30): "); scanf("%s",&workGame.developer); elemSearch=3; search(elemSearch,workGame); yes_no=1; } else if (menuItemSearch==4) { printf("Enter Publisher (MAX-30): "); scanf("%s",&workGame.publisher); elemSearch=4; search(elemSearch,workGame); yes_no=1; } else if (menuItemSearch==5) { printf("Enter Release date (MAX-10): "); scanf("%s",&workGame.releaseDate); elemSearch=5; search(elemSearch,workGame); yes_no=1; } else if (menuItemSearch==6) { printf("Enter Genre (MAX-20): "); scanf("%s",&workGame.genre); elemSearch=6; search(elemSearch,workGame); yes_no=1; } else if (menuItemSearch==7) { printf("Enter Homepage (MAX-20): "); scanf("%s",&workGame.homepage); elemSearch=7; search(elemSearch,workGame); yes_no=1; } else if (menuItemSearch==8) { printf("Enter Transmitter (MAX-10): "); scanf("%s",&workGame.transmitter); elemSearch=8; search(elemSearch,workGame); yes_no=1; } else if (menuItemSearch==9) { printf("Enter Graphics (MAX-10): "); scanf("%s",&workGame.graphics); elemSearch=9; search(elemSearch,workGame); yes_no=1; } else if (menuItemSearch==10) { printf("Enter Age: "); scanf("%d",&workGame.age); elemSearch=10; search(elemSearch,workGame); yes_no=1; } else if (menuItemSearch==11) { printf("Enter Game Rate: "); scanf("%d",&workGame.gameRate); elemSearch=11; search(elemSearch,workGame); yes_no=1; } } } //**Повернення в головне меню. printf("\nEnter '0' for returning in a main menu: "); scanf("%d",&backGo); while (backGo!=0) { printf("You have not enter '0'. Please enter once again: "); scanf("%d",&backGo); } //**Кінець - Повернення в головне меню. back=1; } //**Кінець - Вибір пункту 6. //**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ВИБІР ПУНКТУ '7'.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@. else if (menuItem==7) { printf("Thanks for using a programm. Good bye!!!\n"); } //**Кінець - Вибір пункту 7. //**Не вибрано жодного пункту. else { printf("You have not chosen any menu item. Please enter once again: "); scanf("%d",&menuItem); back=0; } //**Кінець - Не вибрано жодного пункту. } while (menuItem != menuExit); //***Кінець - Перевірка виходу з програми. } //***Кінець - Перший метод. //?????????????????????????????????????????????????????????????????????????????????????????????? //Другий метод else if (method==2) { do { //***Перевірка виводу головного меню. if (back==1) { system("cls"); printf(" You chosen a method 1.\n"); printf(" Menu:\n1. Creat a new database.\n2. Main funcions. \n3. Revision bases given. \n4. Search in the database. \n5. Close a programm.\n"); printf("Choose and enter one of menu items: "); scanf("%d",&menuItem); } //***Кінець - Перевірка виводу головного меню. //**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ВИБІР ПУНКТУ '1'.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ if (menuItem==1) { menuItemP=0; printf("\n Do you want to create a new database? The old database will be deleted.\n"); printf("1. Yes\n2. No\n"); printf("Choose and enter one of menu items: "); scanf("%d",&menuItemP); //**Перевірка вибраний пункт підменю головного меню чи ні. if (menuItemP==1 || menuItemP==2) { yes_no=1; } else { yes_no=0; } //*Перевірка чи потрібно виконувати цикл, якщо не вибраний пункт підменю. while (yes_no!=1) { printf("You have not chosen any menu item. Please enter once again: "); scanf("%d",&menuItemP); if (menuItemP==1 || menuItemP==2) { yes_no=1; } } //*Кінець - Перевірка чи потрібно виконувати цикл, якщо не вибраний пункт підменю. //**Кінець - Перевірка вибраний пункт підменю головного меню чи ні. if (menuItemP==1) { //Потрібно створювати базу даних??? printf("\nEnter name of the file (MAX-20): "); scanf("%s",&nameOfFile); //Введення назви файлу бази даних. strcat(nameOfFile,".txt"); //Додавання розширення .txt до імені. //**Перевірка чи створений файл бази даних чи ні та виведення результату. if ((fileDatabase=fopen(nameOfFile,"w")) == NULL) { printf("\nAn error is at creation of file. %s.",nameOfFile); } else { printf("\nA file is successfully creation. Name of file %s.",nameOfFile); } //**Кінець - Перевірка чи створений файл бази даних чи ні та виведення результату. //*Перевірка чи закритий файл бази даних чи ні та виведення результату. if (fclose(fileDatabase) != 0) { printf("\nAn error is at closing of file %s.",nameOfFile); } else { printf("\nA file is successfully closed."); } //*Кінець - Перевірка чи закритий файл бази даних чи ні та виведення результату. } //**Повернення в головне меню. printf("\nEnter '0' for returning in a main menu: "); scanf("%d",&backGo); while (backGo!=0) { printf("You have not enter '0'. Please enter once again: "); scanf("%d",&backGo); } //**Кінець - Повернення в головне меню. back=1; //Вивід головного меню дозволений. } //**Кінець - Вибір пункту 1. //**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ВИБІР ПУНКТУ '2'.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@. else if (menuItem==2) { menuItemP=0; char words[250]; int n=0; FILE *fGr; printf("\nEnter the name database which you want to open (MAX-20): "); scanf("%s",&nameOfDatabase); //Введення назви файлу бази даних. strcat(nameOfDatabase,".txt"); //Додавання розширення .txt до імені. if ((fileDatabase=fopen(nameOfDatabase,"r+")) == NULL) { printf("\nAn error is at opening of database. %s.",nameOfDatabase); } while(fgets(words,250,fileDatabase) != NULL && words[0] != '\n') { n++; } if (fclose(fileDatabase) != 0) { printf("\nAn error is at closing of file %s.",nameOfDatabase); } if ((f=fopen(nameOfDatabase,"r+")) == NULL) { printf("\nAn error is at opening of database. %s.",nameOfDatabase); } if ((fTemp=fopen("temp.txt","w")) == NULL) { printf("\nAn error is at opening of database. %s.",nameOfDatabase); } if ((fGr=fopen("gr.txt","w")) == NULL) { printf("\nAn error is at opening of database. %s.",nameOfDatabase); } yes_no=0; int menuItemF; //Змінна для збереження вибору меню. int nOp=0; //Змінна для збереження операції, яку потрібно зробити(вставка, редагування, видалення) int yes_noGameRate=0; //Змінна для вибору оцінки гри. struct gameM2Edit zenGame; //Структура потрібна для сортування структур. while (yes_no!=1) { system("cls"); printf("\nWhat you want to do: "); printf("\n1. Add an element.\n2. Edit an element.\n3. Delete an element.\n4. Start a modification of database.\n5. Back.\n"); printf("Choose and enter one of menu items: "); scanf("%d",&menuItemF); //***Введення даних. if (menuItemF==1) { printf("\nEnter next information for a record in a database."); printf("\n1. Enter ID of the game: "); scanf("%d",&zenGame.ID); printf("2. Enter platform (MAX-10): "); scanf("%s",&zenGame.platform); printf("3. Enter name of the game (MAX-40): "); scanf("%s",&zenGame.name); printf("4. Enter developer (MAX-30): "); scanf("%s",&zenGame.developer); printf("5. Enter publisher (MAX-30): "); scanf("%s",&zenGame.publisher); printf("6. Enter release date (MAX-10): "); scanf("%s",&zenGame.releaseDate); printf("7. Enter genre (MAX-20): "); scanf("%s",&zenGame.genre); printf("8. Enter homepage (MAX-20): "); scanf("%s",&zenGame.homepage); printf("9. Enter transmitter (MAX-10): "); scanf("%s",&zenGame.transmitter); printf("10. Enter graphics (MAX-10): "); scanf("%s",&zenGame.graphics); printf("11. Enter age (MAX-3): "); scanf("%d",&zenGame.age); printf("12. Enter game rate (1,2,3,4 or 5): "); scanf("%d",&zenGame.gameRate); if (zenGame.gameRate==1 || zenGame.gameRate==2 || zenGame.gameRate==3 || zenGame.gameRate==4 || zenGame.gameRate== 5) { yes_noGameRate=1; } while (yes_noGameRate!=1) { printf("You have not enter 1, 2, 3, 4 or 5. Please enter once again: "); scanf("%d",&zenGame.gameRate); if (zenGame.gameRate==1 || zenGame.gameRate==2 || zenGame.gameRate==3 || zenGame.gameRate==4 || zenGame.gameRate== 5) { yes_noGameRate=1; } } //***Кінець - Введення даних. zenGame.what=1; //Зберігання, що потрібно робити зі структурою. //**Вивід даних. printf("\n----------------------------------"); printf("\nYour dates:\n"); printf("\nID: %d\nPlatform: %s\nName: %s\nDeveloper: %s\nPublisher: %s\nRelease date: %s\nGenre: %s\nHomepage: %s\nTransmitter: %s\nGraphics: %s\nAge: %d\nGame rate: %d\nDo: %d\n",zenGame.ID,zenGame.platform,zenGame.name,zenGame.developer,zenGame.publisher,zenGame.releaseDate,zenGame.genre,zenGame.homepage,zenGame.transmitter,zenGame.graphics,zenGame.age,zenGame.gameRate,zenGame.what); printf("\n----------------------------------\n"); //**Кінець - Вивід даних. nOp++; fprintf(fGr,"%d %d %s ",zenGame.what, zenGame.ID,zenGame.platform); fprintf(fGr,"%s %s ",zenGame.name,zenGame.developer); fprintf(fGr,"%s %s ",zenGame.publisher,zenGame.releaseDate); fprintf(fGr,"%s %s ",zenGame.genre,zenGame.homepage); fprintf(fGr,"%s %s ",zenGame.transmitter,zenGame.graphics); fprintf(fGr,"%d %d\n",zenGame.age,zenGame.gameRate); } else if (menuItemF==2) { printf("\nEnter ID of element to edit: "); scanf("%d",&zenGame.ID); zenGame.what=2; fprintf(fGr,"%d %d ",zenGame.what, zenGame.ID); yes_no=0; int menuItemEdit; //Змінна для збереження вибору меню. int yes_noP=0; while (yes_noP!=1) { system("cls"); printf("%d\n",nOp); printf("\nWhat you want to edit: "); printf("\n1. Platform\n2. Name\n3. Developer\n4. Publisher\n5. Release date\n6. Genre\n7. Homepage\n8. Transmitter\n9. Graphics\n10. Age\n11. Game rate\n"); printf("Choose and enter one of menu items: "); scanf("%d",&menuItemEdit); if (menuItemEdit==1) { printf("Enter platform (MAX-10): "); scanf("%s",&zenGame.platform); zenGame.whatEdit=1; fprintf(fGr,"%d %s\n",zenGame.whatEdit, zenGame.platform); yes_noP=1; } else if (menuItemEdit==2) { printf("Enter name (MAX-40): "); scanf("%s",&zenGame.name); zenGame.whatEdit=2; fprintf(fGr,"%d %s\n",zenGame.whatEdit, zenGame.name); yes_noP=1; } else if (menuItemEdit==3) { printf("Enter Developer (MAX-30): "); scanf("%s",&zenGame.developer); zenGame.whatEdit=3; fprintf(fGr,"%d %s\n",zenGame.whatEdit, zenGame.developer); yes_noP=1; } else if (menuItemEdit==4) { printf("Enter Publisher (MAX-30): "); scanf("%s",&zenGame.publisher); zenGame.whatEdit=4; fprintf(fGr,"%d %s\n",zenGame.whatEdit, zenGame.publisher); yes_noP=1; } else if (menuItemEdit==5) { printf("Enter Release date (MAX-10): "); scanf("%s",&zenGame.releaseDate); zenGame.whatEdit=5; fprintf(fGr,"%d %s\n",zenGame.whatEdit, zenGame.releaseDate); yes_noP=1; } else if (menuItemEdit==6) { printf("Enter Genre (MAX-20): "); scanf("%s",&zenGame.genre); zenGame.whatEdit=6; fprintf(fGr,"%d %s\n",zenGame.whatEdit, zenGame.genre); yes_noP=1; } else if (menuItemEdit==7) { printf("Enter Homepage (MAX-20): "); scanf("%s",&zenGame.homepage); zenGame.whatEdit=7; fprintf(fGr,"%d %s\n",zenGame.whatEdit, zenGame.homepage); yes_noP=1; } else if (menuItemEdit==8) { printf("Enter Transmitter (MAX-10): "); scanf("%s",&zenGame.transmitter); zenGame.whatEdit=8; fprintf(fGr,"%d %s\n",zenGame.whatEdit, zenGame.transmitter); yes_noP=1; } else if (menuItemEdit==9) { printf("Enter Graphics (MAX-10): "); scanf("%s",&zenGame.graphics); zenGame.whatEdit=9; fprintf(fGr,"%d %s\n",zenGame.whatEdit, zenGame.graphics); yes_noP=1; } else if (menuItemEdit==10) { printf("Enter Age: "); scanf("%d",&zenGame.age); zenGame.whatEdit=10; fprintf(fGr,"%d %d\n",zenGame.whatEdit, zenGame.age); yes_noP=1; } else if (menuItemEdit==11) { printf("Enter Game Rate: "); scanf("%d",&zenGame.gameRate); zenGame.whatEdit=11; fprintf(fGr,"%d %d\n",zenGame.whatEdit, zenGame.gameRate); yes_noP=1; } } nOp++; } else if (menuItemF==3) { printf("\nEnter ID of element to delete: "); scanf("%d",&zenGame.ID); zenGame.what=3; fprintf(fGr,"%d %d\n",zenGame.what, zenGame.ID); nOp++; } else if (menuItemF==4) { int i,j; struct gameM2Edit allGame[20]; //Масив структур для збереження даних; if (fclose(fGr) != 0) { printf("\nAn error is at closing of file gr.txt."); } if ((fGr=fopen("gr.txt","r+")) == NULL) { printf("\nAn error is at opening of database. %s.",nameOfDatabase); } printf("\nnOp = %d\n",nOp); for (i=0; i<nOp; i++) { char one[40]; char *end; fscanf(fGr,"%s",&one); allGame[i].what=strtol(one,&end,10); fscanf(fGr,"%c"); if (allGame[i].what==1) { for (j=0;j<12;j++) { fscanf(fGr,"%s",&one); if (j==0) { allGame[i].ID=strtol(one,&end,10); fscanf(fGr,"%c"); } else if (j==1) { strcpy(allGame[i].platform,one); fscanf(fGr,"%c"); } else if (j==2) { strcpy(allGame[i].name,one); fscanf(fGr,"%c"); } else if (j==3) { strcpy(allGame[i].developer,one); fscanf(fGr,"%c"); } else if (j==4) { strcpy(allGame[i].publisher,one); fscanf(fGr,"%c"); } else if (j==5) { strcpy(allGame[i].releaseDate,one); fscanf(fGr,"%c"); } else if (j==6) { strcpy(allGame[i].genre,one); fscanf(fGr,"%c"); } else if (j==7) { strcpy(allGame[i].homepage,one); fscanf(fGr,"%c"); } else if (j==8) { strcpy(allGame[i].transmitter,one); fscanf(fGr,"%c"); } else if (j==9) { strcpy(allGame[i].graphics,one); fscanf(fGr,"%c"); } else if (j==10) { allGame[i].age=strtol(one,&end,10); fscanf(fGr,"%c"); } else if (j==11) { allGame[i].gameRate=strtol(one,&end,10); } } } else if (allGame[i].what==2) { fscanf(fGr,"%s",&one); allGame[i].ID=strtol(one,&end,10); fscanf(fGr,"%c"); fscanf(fGr,"%s",&one); allGame[i].whatEdit=strtol(one,&end,10); fscanf(fGr,"%c"); fscanf(fGr,"%s",&one); if (allGame[i].whatEdit==0) { } else if (allGame[i].whatEdit==1) { strcpy(allGame[i].platform,one); fscanf(fGr,"%c"); } else if (allGame[i].whatEdit==2) { strcpy(allGame[i].name,one); fscanf(fGr,"%c"); } else if (allGame[i].whatEdit==3) { strcpy(allGame[i].developer,one); fscanf(fGr,"%c"); } else if (allGame[i].whatEdit==4) { strcpy(allGame[i].publisher,one); fscanf(fGr,"%c"); } else if (allGame[i].whatEdit==5) { strcpy(allGame[i].releaseDate,one); fscanf(fGr,"%c"); } else if (allGame[i].whatEdit==6) { strcpy(allGame[i].genre,one); fscanf(fGr,"%c"); } else if (allGame[i].whatEdit==7) { strcpy(allGame[i].homepage,one); fscanf(fGr,"%c"); } else if (allGame[i].whatEdit==8) { strcpy(allGame[i].transmitter,one); fscanf(fGr,"%c"); } else if (allGame[i].whatEdit==9) { strcpy(allGame[i].graphics,one); fscanf(fGr,"%c"); } else if (allGame[i].whatEdit==10) { allGame[i].age=strtol(one,&end,10); fscanf(fGr,"%c"); } else if (allGame[i].whatEdit==11) { allGame[i].gameRate=strtol(one,&end,10); } } else if (allGame[i].what==3) { fscanf(fGr,"%s",&one); allGame[i].ID=strtol(one,&end,10); } } if (fclose(fGr) != 0) { printf("\nAn error is at closing of file gr.txt."); } //***Сортування for (i=0; i<nOp; i++) { for (j=0; j<nOp-1; j++) { if (allGame[j].ID>allGame[j+1].ID) { zenGame.ID=allGame[j].ID; strcpy(zenGame.platform,allGame[j].platform); strcpy(zenGame.name,allGame[j].name); strcpy(zenGame.developer,allGame[j].developer); strcpy(zenGame.publisher,allGame[j].publisher); strcpy(zenGame.releaseDate,allGame[j].releaseDate); strcpy(zenGame.genre,allGame[j].genre); strcpy(zenGame.homepage,allGame[j].homepage); strcpy(zenGame.transmitter,allGame[j].transmitter); strcpy(zenGame.graphics,allGame[j].graphics); zenGame.age=allGame[j].age; zenGame.gameRate=allGame[j].gameRate; zenGame.what=allGame[j].what; zenGame.whatEdit=allGame[j].whatEdit; allGame[j].ID=allGame[j+1].ID; strcpy(allGame[j].platform,allGame[j+1].platform); strcpy(allGame[j].name,allGame[j+1].name); strcpy(allGame[j].developer,allGame[j+1].developer); strcpy(allGame[j].publisher,allGame[j+1].publisher); strcpy(allGame[j].releaseDate,allGame[j+1].releaseDate); strcpy(allGame[j].genre,allGame[j+1].genre); strcpy(allGame[j].homepage,allGame[j+1].homepage); strcpy(allGame[j].transmitter,allGame[j+1].transmitter); strcpy(allGame[j].graphics,allGame[j+1].graphics); allGame[j].age=allGame[j+1].age; allGame[j].gameRate=allGame[j+1].gameRate; allGame[j].what=allGame[j+1].what; allGame[j].whatEdit=allGame[j+1].whatEdit; allGame[j+1].ID=zenGame.ID; strcpy(allGame[j+1].platform,zenGame.platform); strcpy(allGame[j+1].name,zenGame.name); strcpy(allGame[j+1].developer,zenGame.developer); strcpy(allGame[j+1].publisher,zenGame.publisher); strcpy(allGame[j+1].releaseDate,zenGame.releaseDate); strcpy(allGame[j+1].genre,zenGame.genre); strcpy(allGame[j+1].homepage,zenGame.homepage); strcpy(allGame[j+1].transmitter,zenGame.transmitter); strcpy(allGame[j+1].graphics,zenGame.graphics); allGame[j+1].age=zenGame.age; allGame[j+1].gameRate=zenGame.gameRate; allGame[j+1].what=zenGame.what; allGame[j+1].whatEdit=zenGame.whatEdit; } } } //**Кінець - Сортування структур. //***Вивід даних, якими потрібно модифікувати базу даних. int m; if ((fGr=fopen("gr.txt","w")) == NULL) { printf("\nAn error is at opening of database. %s.",nameOfDatabase); } if (nOp>0) { for (m=0; m<nOp; m++) { if (allGame[m].what==1) { //Додавання запису. printf("\n%d. Add a record:\n",m); //**Вивід даних. printf("\n----------------------------------"); printf("\nYour dates:\n"); printf("\nID: %d\nPlatform: %s\nName: %s\nDeveloper: %s\nPublisher: %s\nRelease date: %s\nGenre: %s\nHomepage: %s\nTransmitter: %s\nGraphics: %s\nAge: %d\nGame rate: %d\n",allGame[m].ID,allGame[m].platform,allGame[m].name,allGame[m].developer,allGame[m].publisher,allGame[m].releaseDate,allGame[m].genre,allGame[m].homepage,allGame[m].transmitter,allGame[m].graphics,allGame[m].age,allGame[m].gameRate); printf("\n----------------------------------\n"); fprintf(fGr,"%d %d %s ",allGame[m].ID,allGame[m].what,allGame[m].platform); fprintf(fGr,"%s %s ",allGame[m].name,allGame[m].developer); fprintf(fGr,"%s %s ",allGame[m].publisher,allGame[m].releaseDate); fprintf(fGr,"%s %s ",allGame[m].genre,allGame[m].homepage); fprintf(fGr,"%s %s ",allGame[m].transmitter,allGame[m].graphics); fprintf(fGr,"%d %d\n",allGame[m].age,allGame[m].gameRate); //**Кінець - Вивід даних. } else if (allGame[m].what==2) {//Редагування запису. printf("\n%d. Edit a record:\n",m); printf("\nID: %d\n",allGame[m].ID); fprintf(fGr,"%d %d ",allGame[m].ID,allGame[m].what); if (allGame[m].whatEdit==1) { printf("\nPlatform: %s\n",allGame[m].platform); fprintf(fGr,"%d %s\n",allGame[m].whatEdit,allGame[m].platform); } else if (allGame[m].whatEdit==2) { printf("\nName: %s\n",allGame[m].name); fprintf(fGr,"%d %s\n",allGame[m].whatEdit,allGame[m].name); } else if (allGame[m].whatEdit==3) { printf("\nDeveloper: %s\n",allGame[m].developer); fprintf(fGr,"%d %s\n",allGame[m].whatEdit,allGame[m].developer); } else if (allGame[m].whatEdit==4) { printf("\nPublisher: %s\n",allGame[m].publisher); fprintf(fGr,"%d %s\n",allGame[m].whatEdit,allGame[m].publisher); } else if (allGame[m].whatEdit==5) { printf("\nReleaseDate: %s\n",allGame[m].releaseDate); fprintf(fGr,"%d %s\n",allGame[m].whatEdit,allGame[m].releaseDate); } else if (allGame[m].whatEdit==6) { printf("\nGenre: %s\n",allGame[m].genre); fprintf(fGr,"%d %s\n",allGame[m].whatEdit,allGame[m].genre); } else if (allGame[m].whatEdit==7) { printf("\nHomepage: %s\n",allGame[m].homepage); fprintf(fGr,"%d %s\n",allGame[m].whatEdit,allGame[m].homepage); } else if (allGame[m].whatEdit==8) { printf("\nTransmitter: %s\n",allGame[m].transmitter); fprintf(fGr,"%d %s\n",allGame[m].whatEdit,allGame[m].transmitter); } else if (allGame[m].whatEdit==9) { printf("\nGraphics: %s\n",allGame[m].graphics); fprintf(fGr,"%d %s\n",allGame[m].whatEdit,allGame[m].graphics); } else if (allGame[m].whatEdit==10) { printf("\nAge: %d\n",allGame[m].age); fprintf(fGr,"%d %d\n",allGame[m].whatEdit,allGame[m].age); } else if (allGame[m].whatEdit==11) { printf("\nGameRate: %d\n",allGame[m].gameRate); fprintf(fGr,"%d %d\n",allGame[m].whatEdit,allGame[m].gameRate); } } else if (allGame[m].what==3) { //Видалення запису. printf("\n%d. Delete a record:\n",m); printf("\nID: %d\n",allGame[m].ID); fprintf(fGr,"%d %d\n",allGame[m].ID,allGame[m].what); } } } if (fclose(fGr) != 0) { printf("\nAn error is at closing of file gr.txt."); } //***Кінець - Вивід даних, якими потрібно модифікувати базу даних. int i_vn=0; //Змінна для зберігання скільки записів додано, редаговано, видалено. for (m=0; m<n; m++) { char one[40]; char *end; //Зчитування з файлу запису. for (j=0;j<12;j++) { fscanf(f,"%s",&one); if (j==0) { zenGame.ID=strtol(one,&end,10); fscanf(f,"%c"); } else if (j==1) { strcpy(zenGame.platform,one); fscanf(f,"%c"); } else if (j==2) { strcpy(zenGame.name,one); fscanf(f,"%c"); } else if (j==3) { strcpy(zenGame.developer,one); fscanf(f,"%c"); } else if (j==4) { strcpy(zenGame.publisher,one); fscanf(f,"%c"); } else if (j==5) { strcpy(zenGame.releaseDate,one); fscanf(f,"%c"); } else if (j==6) { strcpy(zenGame.genre,one); fscanf(f,"%c"); } else if (j==7) { strcpy(zenGame.homepage,one); fscanf(f,"%c"); } else if (j==8) { strcpy(zenGame.transmitter,one); fscanf(f,"%c"); } else if (j==9) { strcpy(zenGame.graphics,one); fscanf(f,"%c"); } else if (j==10) { zenGame.age=strtol(one,&end,10); fscanf(f,"%c"); } else if (j==11) { zenGame.gameRate=strtol(one,&end,10); } } //Кінець - Зчитування з файлу запису. //***Модифікація бази даних. if (allGame[i_vn].ID<=zenGame.ID) { //Якщо ID менший або рівний, інакше записати в temp. if (i_vn<nOp) { //Всі записи пройдені, інакше записати в temp. printf("\ni_vn = %d",i_vn); //Якщо 3 ID рівні. if (allGame[i_vn].ID==allGame[i_vn+1].ID && allGame[i_vn].ID==allGame[i_vn+2].ID) { if (allGame[i_vn+2].what==3) { printf("\nAdd, edit, delete. Nichoho ne potribno robutu"); } i_vn=i_vn+3; //Пройдені 3 записи. } //Якщо 2 ID рівні. else if (allGame[i_vn].ID==allGame[i_vn+1].ID) { //Додати редагувати?? if (allGame[i_vn].what==1 && allGame[i_vn+1].what==2) { printf("\nAdd, edit."); if (allGame[i_vn+1].whatEdit==1) { strcpy(allGame[i_vn].platform,allGame[i_vn+1].platform); } else if (allGame[i_vn+1].whatEdit==2) { strcpy(allGame[i_vn].name,allGame[i_vn+1].name); } else if (allGame[i_vn+1].whatEdit==3) { strcpy(allGame[i_vn].developer,allGame[i_vn+1].developer); } else if (allGame[i_vn+1].whatEdit==4) { strcpy(allGame[i_vn].publisher,allGame[i_vn+1].publisher); } else if (allGame[i_vn+1].whatEdit==5) { strcpy(allGame[i_vn].releaseDate,allGame[i_vn+1].releaseDate); } else if (allGame[i_vn+1].whatEdit==6) { strcpy(allGame[i_vn].genre,allGame[i_vn+1].genre); } else if (allGame[i_vn+1].whatEdit==7) { strcpy(allGame[i_vn].homepage,allGame[i_vn+1].homepage); } else if (allGame[i_vn+1].whatEdit==8) { strcpy(allGame[i_vn].transmitter,allGame[i_vn+1].transmitter); } else if (allGame[i_vn+1].whatEdit==9) { strcpy(allGame[i_vn].graphics,allGame[i_vn+1].graphics); } else if (allGame[i_vn+1].whatEdit==10) { allGame[i_vn].age=allGame[i_vn+1].age; } else if (allGame[i_vn+1].whatEdit==11) { allGame[i_vn].gameRate=allGame[i_vn+1].gameRate; } fprintf(fTemp,"%d %s ",allGame[i_vn].ID,allGame[i_vn].platform); fprintf(fTemp,"%s %s ",allGame[i_vn].name,allGame[i_vn].developer); fprintf(fTemp,"%s %s ",allGame[i_vn].publisher,allGame[i_vn].releaseDate); fprintf(fTemp,"%s %s ",allGame[i_vn].genre,allGame[i_vn].homepage); fprintf(fTemp,"%s %s ",allGame[i_vn].transmitter,allGame[i_vn].graphics); fprintf(fTemp,"%d %d\n",allGame[i_vn].age,allGame[i_vn].gameRate); fprintf(fTemp,"%d %s ",zenGame.ID,zenGame.platform); fprintf(fTemp,"%s %s ",zenGame.name,zenGame.developer); fprintf(fTemp,"%s %s ",zenGame.publisher,zenGame.releaseDate); fprintf(fTemp,"%s %s ",zenGame.genre,zenGame.homepage); fprintf(fTemp,"%s %s ",zenGame.transmitter,zenGame.graphics); fprintf(fTemp,"%d %d\n",zenGame.age,zenGame.gameRate); } //Додати і видалити?? else if (allGame[i_vn].what==1 && allGame[i_vn+1].what==3) { printf("\nAdd, delete: nichoho ne potribno robutu"); } //Редагувати і видалити?? else if (allGame[i_vn].what==2 && allGame[i_vn+1].what==3) { printf("\nEdit, delete: nichoho ne potribno robutu"); } i_vn=i_vn+2; //2 записи пройдені. } else { if (allGame[i_vn].ID<zenGame.ID) { //ID менший??? if (allGame[i_vn].what==1) { //Додати запис?? printf("\nAdd element."); fprintf(fTemp,"%d %s ",allGame[i_vn].ID,allGame[i_vn].platform); fprintf(fTemp,"%s %s ",allGame[i_vn].name,allGame[i_vn].developer); fprintf(fTemp,"%s %s ",allGame[i_vn].publisher,allGame[i_vn].releaseDate); fprintf(fTemp,"%s %s ",allGame[i_vn].genre,allGame[i_vn].homepage); fprintf(fTemp,"%s %s ",allGame[i_vn].transmitter,allGame[i_vn].graphics); fprintf(fTemp,"%d %d\n",allGame[i_vn].age,allGame[i_vn].gameRate); fprintf(fTemp,"%d %s ",zenGame.ID,zenGame.platform); fprintf(fTemp,"%s %s ",zenGame.name,zenGame.developer); fprintf(fTemp,"%s %s ",zenGame.publisher,zenGame.releaseDate); fprintf(fTemp,"%s %s ",zenGame.genre,zenGame.homepage); fprintf(fTemp,"%s %s ",zenGame.transmitter,zenGame.graphics); fprintf(fTemp,"%d %d\n",zenGame.age,zenGame.gameRate); } else if (allGame[i_vn].what==2 || allGame[i_vn].what==3) { printf("\nSuch element is not in a database."); } } else if (allGame[i_vn].ID==zenGame.ID) { if (allGame[i_vn].what==2) { //Редагувати запис?? printf("\nEdit element."); if (allGame[i_vn].whatEdit==1) { strcpy(zenGame.platform,allGame[i_vn].platform); } else if (allGame[i_vn].whatEdit==2) { strcpy(zenGame.name,allGame[i_vn].name); } else if (allGame[i_vn].whatEdit==3) { strcpy(zenGame.developer,allGame[i_vn].developer); } else if (allGame[i_vn].whatEdit==4) { strcpy(zenGame.publisher,allGame[i_vn].publisher); } else if (allGame[i_vn].whatEdit==5) { strcpy(zenGame.releaseDate,allGame[i_vn].releaseDate); } else if (allGame[i_vn].whatEdit==6) { strcpy(zenGame.genre,allGame[i_vn].genre); } else if (allGame[i_vn].whatEdit==7) { strcpy(zenGame.homepage,allGame[i_v
Антиботан аватар за замовчуванням

2015

Коментарі

Ви не можете залишити коментар. Для цього, будь ласка, увійдіть або зареєструйтесь.

Ділись своїми роботами та отримуй миттєві бонуси!

Нічого не вибрано
0%

Оголошення від адміністратора

Антиботан аватар за замовчуванням

Подякувати Студентському архіву довільною сумою

Admin

26.02.2023 12:38

Дякуємо, що користуєтесь нашим архівом!