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

The Text file Problem Statement The 911 service is developing an application tha

ID: 3776528 • Letter: T

Question

The Text file

Problem Statement The 911 service is developing an application that will help the dispatcher attending emergency calls, to find the nearest/closest service to the place where the emergency occurred. Depending on the event type, the dispatcher will need to get in contact with the POLICE DEPARTMENT, a HOSPITAL or FIRE STATION Each of these services will be identified by i. Service id: A unique integer identifying the service( service id ii. X-Coordinate: a double used to store longitude( coordinate iii. Y-Coordinate: a double used to store latitude( coordinate y iv. Service Type: an enumerator to identify POLICE DEPARTMENT -0, HOSPITAL -l, FIRE STATION (SERVICE TYPE) v. City Name: A c-string (char to store the name of the city where the service is located city name The information is given as an input file (named serviceInfo.txt) with a list like 215.4 PLANO 123.5 PLANO 178.4 123.5 PLANO 385.4 76.5 215.4 255.5 RICHARDSON NOTE: The file serviceInfo.txt should be located at the same folder/directory as your .c file, and may include a header line(i.e. the name for each column)

Explanation / Answer

(b) #include <stdio.h>
struct s {

int id;
int location;
int servicetype;
char policedepartment[40];
char hospital[40];
char cityname[40];
char firestation[40];
};
int main() {
struct s a[40],b[40];
FILE *fptr;
int i;
int min=array[0];
fptr=fopen("file.txt","wb");
for (i=0;i<40;++i) {
fflush(stdin);
printf("Enter id: ");
scanf("%d",&a[i].id);
printf("Enter x: ");
gets(a[i].x);
printf("Enter y: ");
scanf("%d",&a[i].y);
printf("Enter service type: ");
scanf("%d",&a[i].servicetype);
printf("Enter cityname: ");
scanf("%s",&a[i].cityname);
}
fwrite(a,sizeof(a),1,fptr);
fclose(fptr);
fptr=fopen("file.txt","rb");
fread(b,sizeof(b),1,fptr);
for (i=0;i<40;++i) {
printf("id: %d policedepartment: %s hospital: %s firestation:
%s service type: %d cityname: %s location(%d,
%d)",b[i].id,b[i].service type,b[i].cityname,b[i].location);
if (b[i].location<min)
min=b[i].location;
if min==b[i].location
printf("servicetype: %d ',b[i].service type)
printf("hospital: %s ',b[i].hospital)
printf("policedepartment: %s ',b[i].policedepartment)
printf("firestation: %s ',b[i].firestation)



}
fclose(fptr);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote