Professional Documents
Culture Documents
Couriermanagementsystem
Couriermanagementsystem
1. Insert module: This module is responsible for inserting new data into the system. In the context
of a courier management system, this could include information about new packages, delivery addresses,
or customers. The insert module would typically prompt the user for the relevant information, validate it for
correctness and completeness, and then store it in the system's database.
2. Display module: The display module is responsible for retrieving and displaying data from the
system. In the context of a courier management system, this module could be used to display information
about existing packages, delivery schedules, or customer accounts. The display module would typically
allow the user to search for specific records, filter records by certain criteria, and sort records based on
different fields.
3. Search module: The search module is used to retrieve specific records from the system's
database. In the context of a courier management system, this module could be used to search for
specific packages, customer accounts, or delivery schedules. The search module would typically
allow the user to enter search criteria, such as a package ID or customer name, and then retrieve
all records that match the specified criteria.
4. Delete/Update module: The delete/update module is responsible for modifying or
removing existing records from the system's database. In the context of a courier management
system, this module could be used to update the status of a package, change a delivery schedule,
or delete a customer account. The delete/update module would typically prompt the user for the
relevant information and then make the necessary changes to the database.
5. Sort module: The sort module is used to sort records in the system's database based on
different fields. In the context of a courier management system, this module could be used to sort
packages by delivery date, customers by name, or delivery schedules by route. The sort module
would typically allow the user to select a field to sort by, such as a package's delivery date, and
then display the records in ascending or descending order based on that field.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Courier {
char name[50];
int id;
char address[100];
char phone[20];
};
//INSERT MODULE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Courier {
char name[50];
char address[100];
char phone[20];
char email[50];
};
int main() {
struct Courier courier;
FILE *fp;
fp = fopen("courier_data.txt", "a");
if(fp == NULL) {
printf("Error opening file!\n");
exit(1);
}
printf("Enter Name:");
// fgets(courier.name, 50, stdin);
fscanf(stdin, "%49[^\n]%*c", courier.name);
printf("Enter address: ");
// fgets(courier.address, 100, stdin);
fscanf(stdin, "%99[^\n]%*c", courier.address);
printf("Enter phone: ");
// fgets(courier.phone, 20, stdin);
fscanf(stdin, "%19[^\n]%*c", courier.phone);
printf("Enter email: ");
// fgets(courier.email, 50, stdin);
fscanf(stdin, "%49[^\n]%*c", courier.email);
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Courier {
char name[50];
char address[100];
char phone[20];
char email[50];
};
int main() {
struct Courier courier;
FILE *fp;
fp = fopen("courier_data.txt", "r");
if(fp == NULL) {
printf("Error opening file!\n");
exit(1);
}
printf("Courier data:\n");
printf("--------------------------------------------------------------------\n");
printf("Name\t\tAddress\t\tPhone\t\tEmail\n");
printf("--------------------------------------------------------------------\n");
//SEARCH MODULE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Courier {
char name[50];
char address[100];
char phone[20];
char email[50];
};
int main() {
struct Courier courier;
char search_name[50];
FILE *fp;
fp = fopen("courier_data.txt", "r");
if(fp == NULL) {
printf("Error opening file!\n");
exit(1);
}
int found = 0;
if(!found) {
printf("No data found for '%s'\n", search_name);
}
printf("--------------------------------------------------------------------\n");
fclose(fp);
return 0;
}
Output of Search Module
//DELETE/UPDATE MODULE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Courier {
char name[50];
char address[100];
char phone[20];
char email[50];
};
int main() {
fp = fopen("courier_data.txt", "r");
exit(1);
scanf("%d", &option);
if(option == 1) {
scanf("%s", search_name);
if(strcmp(courier.name, search_name) != 0) {
fprintf(temp_fp, "%s %s %s %s\n", courier.name, courier.address, courier.phone,
courier.email);
} else {
found = 1;
if(!found) {
} else {
} else if(option == 2) {
scanf("%s", search_name);
if(strcmp(courier.name, search_name) != 0) {
} else {
found = 1;
scanf("%s", new_phone);
scanf("%s", new_email);
if(!found) {
} else {
printf("Invalid option\n");
exit(1);
fclose(fp);
fclose(temp_fp);
remove("courier_data.txt");
rename("temp_courier_data.txt", "courier_data.txt");
return 0;
//SORT MODULE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Courier {
char name[50];
char address[100];
char phone[20];
char email[50];
};
int main() {
int i = 0, j, n;
FILE *fp;
fp = fopen("courier_data.txt", "r");
if(fp == NULL) {
exit(1);
i++;
}
n = i;
courier[i] = courier[j];
courier[j] = temp;
fclose(fp);
fp = fopen("courier_data.txt", "w");
fclose(fp);
printf("Data sorted successfully\n");
return 0;
Unsorted data
Sorted data
DFD (Data Flow Diagram)
Level 0:
Level 1: