Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Programming: here are the requirements: Write a program which expects the name of an input file and an output file to be given by

C Programming:

here are the requirements:

Write a program which expects the name of an input file and an output file to be given by the user. If the user does not input any names, default file names should be used, such as in.txt, and out.txt. The input files have lines which look like this:

North Carolina,Chapel Hill:70 The number after the state/city is a high temperature. Any state/city can be represented any number of times in the input file. Your program will create an output file which contains each city/state followed by the average high temperature to one decimal place such as:

North Carolina,Chapel Hill:76.4 Read data from the first input file into a dynamically allocated array of CITY structures. You may assume that the maximum size of a state/city string is 100. Display the array to the screen. The program should use the insertion sort algorithm to sort the data in state/city order. To demonstrate that the sorting algorithm works, display the array after sorting. Create your own input file using the data shown below. On the first line in the input file provide the number of state/city lines. Make sure that your program does not produce memory leaks. Memory leak detection is optional (see last page). Run the program once and save the output at the end of the source file as a comment. Compress the source file, input and output files and upload the compressed file: 26B_LastName_FirstName_H1.zip in.txt 27 // number of the line which will need to create a function of

Pennsylvania,Philadelphia:91

California,San Francisco:75

Nevada,Reno:108

Arizona,Flagstaff:81

California,Yreka:101

Arizona,Tucson:107

California,Los Angeles:78

California,Los Angeles:81

Pennsylvania,Pittsburgh:89

Oregon,Salem:90

California,Los Angeles:82

Arizona,Flagstaff:84

California,San Francisco:64 Oregon,Salem:83

California,San Francisco:68

Arizona,Tucson:99

California,Yreka:100

Arizona,Phoenix:109

Oregon,Portland:82

Arizona,Tucson:103

Oregon,Portland:79

Arizona,Phoenix:107

California,Cupertino:88

Oregon,Salem:85

Pennsylvania,Philadelphia:86

California,Los Angeles:97

Nevada,Reno:108

So this is what I have so far and I'm still so confused:

#include #include

#ifdef _MSC_VER #include // needed to check for memory leaks (Windows only!) #endif

int main( void ) { FILE * fPointer; fPointer = fopen("in.txt", "r"); char line[150]; while(!feof(fPointer)){ fgets(line, 150, fPointer); puts(line); }

fclose(fPointer);

#ifdef _MSC_VER printf( _CrtDumpMemoryLeaks() ? "Memory Leak " : "No Memory Leak "); #endif

return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago