Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need someone to send me this in C programming using Visual Studios. Can you al

ID: 3889118 • Letter: I

Question

I need someone to send me this in C programming using Visual Studios. Can you also put comments as guidelines so i would be able to know how to manipulate it to make more than one database. Please provide good steps. Im not looking to take this answer and copy and paste it. I would like to take this and try to use it as a guideline to make my own.

Use pointers

StructDB

READDB

WRITEDB

VOIDDISPDB

LINK

6. Your mission, should you choose to accept it Create a database program to make a list of something of interest to you. The structure must have at least 4 items in it. Your program will use a menu to select an option. You must include create a new database, display the database, write the database to a disk file, read the database from a disk file, and add a new item to the database. You may optionally include delete an item from the data base and modify an entry in the database. We won't worry about sorting. It's a bit complicated. You will include several screen prints showing how your database works, along with your source code. You have two weeks to perform this task. I cannot answer questions you may have via email. You must either ask in class or see me in my office hours. Do not collaborate with anyone else. This must be your own effort. Collaboration will cause severe damage to your grade

Explanation / Answer

#include <stdio.h>
#include <stdlib.h>

/* Creating a structure to hold records of students in a university. Data items include name of the student, roll number, score, and the department to which he/she belongs */
struct student
{
char name[100];
int rollNumber;
char department[100];
float score;
};

// Method for creating a new database
struct student *CreateDatabase()
{
struct student *students = (struct student *)malloc(100*sizeof(struct student));
return students;

}

// Method for displaying the database
void DisplayDatabase(struct student *students, int count)
{
int i;
printf("Displaying database: ");
for(i = 0; i < count; i++)
{
printf("Name: %s, Roll Number: %d, Department: %s, Score: %f ",students[i].name, students[i].rollNumber, students[i].department, students[i].score);
}

}

// Method for adding a record to a database
void AddRecordtoDatabase(struct student *students, int count)
{
printf("Enter information: ");
printf("Enter name: ");
scanf("%s", students[count].name);
printf(" Enter roll number: ");
scanf("%d", &students[count].rollNumber);
printf(" Enter department: ");
scanf("%s", &students[count].department);
printf(" Enter score: ");
scanf("%f", &students[count].score);
}

//Method for writing the database to a file
void WritedatabasetoFile(struct student *students, int count)
{
FILE *ofp;
char filename[] = "C:\Users\SurbhiJindal\Desktop\testfile.txt"; /* Change this name to the name of the file where you want to write the data */


ofp = fopen(filename, "wb");
if (ofp != 0)
{
if (fwrite(students, sizeof(students), 1, ofp) != 1)
{
fprintf(stderr, "Failed to write to %s ", filename);
exit(1);
}
fclose(ofp);
}
}


//Method for reading database from a file

struct student *ReaddatabaseFromFile(char filename[], int count)
{
FILE *ifp;
ifp = fopen(filename, "rb");
struct student *students = (struct student *)malloc(count*sizeof(struct student));
if (ifp != 0)
{
if (fread(students, sizeof(students), 1, ifp) != 1)
{
fprintf(stderr, "Failed to read from %s ", filename);
exit(1);
}
fclose(ifp);
}

return students;
}

int main()
{

int choice, i;
int count = 0;
struct student *students;
while(choice != 6)
{
printf(" MENU ");
printf("1. Create a new database ");
printf("2. Display the database ");
printf("3. Write database to a disk file ");
printf("4. Read the database from a disk file ");
printf("5. Add new item to the database ");
printf("6. Exit ");
printf("Please enter your choice ");
scanf("%d",&choice);

if(choice == 1)
{
students = CreateDatabase();
count = 0;
}

if(choice == 2)
{
DisplayDatabase(students, count);
}

if(choice == 3)
{
WritedatabasetoFile(students, count);
}

if(choice == 4)
{
students = ReaddatabaseFromFile("C:\Users\SurbhiJindal\Desktop\testfile.txt",count); /* change the filename according to what you want */
}

if(choice == 5)
{
AddRecordtoDatabase(students, count);
count = count + 1;
}

}
return 0;
}