#include <stdio.h> #include <stdlib.h> #include <string.h> #define MI 1000 #define MI2…
- User
#include <stdio.h> #include <stdlib.h> #include <string.h>
#define MI 1000 #define MI2 1000 char dataFile [] = "dataofmotorbike.txt"; char a[MI][MI2];
int n; FILE *fi, *fo; void ReadData() { n=0; int i; fi = fopen(dataFile,"r"); if(fi == NULL) { printf("File %s not found!\n",dataFile); printf("Load data fail! Create new data file.\n"); } else { printf("Loading data from %s...",dataFile); fscanf(fi,"%d",&n); for(i=0; i<n; i++) { fscanf(fi,"%s",a[i]); } printf("Done! [%d item(s)]",n);
codefclose(fi); }} void createFile() { fo = fopen(dataFile, "w"); fclose(fo); }
void SaveData() { int i; fo = fopen(dataFile, "w"); //printf("%d", n); fprintf(fo, "%d\n", n); for (i=0; i<n; i++) { fprintf(fo, "%d ", a[i]); } fclose(fo); }
void printList() { int i; printf("List of motorbikes product [%d item(s)]:\n",n); for(i=0; i<n; i++) { printf("%s ",a[i]); } }
int identify() { createFile(); system("cls"); int id=0; printf("======================================================================================\n"); printf("============================ CHOOSE YOUR POSITION ================================\n"); printf("======================================================================================\n"); printf("\n"); printf("= 1. General Manager =\n"); printf("======================================================================================\n"); printf("\n"); printf("============================2. Worker ================================\n"); printf("======================================================================================\n"); printf("**************************************************************************************\n"); printf("============================3. Mystery ================================\n"); printf("======================================================================================\n"); scanf("%d",&id); if(id<1 || id>5) { printf("Please just choose in range from 1 to 3"); } else { if(id==1) return 1; else if(id==2) return 2; else if(id==3) return 3; else if(id==4) { return 4;
- Assistant
The function "chucNang5()" is responsible for removing motorbike(s) by value. However, the implementation of this function is missing in the code snippet provided. It seems that the function has only been declared but not defined. To implement this function, you can follow these steps:
- Define the function "chucNang5()" to remove motorbike(s) by value.
- Inside the function, prompt the user to enter the value of the motorbike(s) they want to remove.
- Use a loop to iterate through the array of motorbikes and check if the entered value matches any motorbike.
- If a match is found, remove the motorbike by shifting all the elements after it one position to the left.
- Update the array size variable "n" accordingly.