/*---------------------------------------------------*/
/*  Program from lecture to demonstrate file-reading */
/*  and file writing                                 */
/*  ECL 9/17/07                                      */

#include <stdio.h>

int main(void)
{
	int num_data_points = 0;	//number of rows of time temp data
	double time=0.0, temp_f=0.0;	//doubles in which we will store Fahrenheit temps
	double temp_c = 0.0;
	FILE *input_file;		//establish a "pointer" to an input file
	FILE *output_file;		//establish a "pointer" to an output file	

	input_file = fopen("time_tempf.txt","r");	//open time_tempf.txt for reading
	fscanf(input_file, "%i", &num_data_points);	//read the number of time_temp combos

	output_file = fopen("time_tempc.txt","w");	//open time_tempc.txt for writing
	fprintf(output_file, "%i\n", num_data_points);	//print the number of time_temp combos

	for(int i = 0; i < num_data_points; i++)
	{
		fscanf(input_file, "%lf %lf", &time, &temp_f);	//read time and temp (i+1)
		temp_c = (5.0/9.0)*(temp_f - 32.0);
		fprintf(output_file, "%.2f %.2f\n", time, temp_c);	//output converted time_temp combos
	}

	fclose(input_file);
	fclose(output_file);

	return 0;
}	
	








