All pastes #421703 Raw Edit

Stuff

public text v1 · immutable
·published 2007-04-03 00:03 UTC
rendered paste body
/**
	proj1.h 
	
	@author elliot@wpi.edu Elliot Pennington
*/

#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/types.h>

#define PI 3.14159265358979323846

typedef struct town { 
	char ID[10]; //unique identifier: a string of up to 8 digits 
	char Name[45]; // as known to the USPS. None is quite as long 
	char state[3]; // the usual two letters (+ string end) 
	double lat, longit; // Short for latitude and longitude, in degrees 
	int Elev; // in meters, above sea-level (some are below...) 
	} Town;

	/**
		Dynamically allocates a new town
		@param char* id
		@param char* nam
		@param char* stat
		@param double lati
		@param double longi
		@param int ele
		@return a freshly allocated town
	*/
	Town* dynAlloc(char* id, char* nam, char* stat, double lati, double longi, int ele);
	
	/**
		Get's the information about a town from a single line of a file, and allocates it
		@param File* inf
		@param Town* t
		@return a new town
	*/
	Town* getStuff(FILE* inf, Town* t);
	
	/**
		Used to copy one town fully into a different town
		@param Town* dest
		@param Town* src
		@return the destination town
	*/
	Town* copyTown(Town* dest, Town* src);
	
	/**
		Used for testing purposes. prints attributes of a town
		@param Town* t
	*/
	void outTown(Town* t);
	
	/**
		counts line in a text file
		@param FILE* stream
		@return the number of lines
	*/
	int nlcount(FILE* stream);
	
	/**
		Chuck norris roundhouse kicks target town, deleting it instantly
		@param Town* t
	*/
	void chucknorris(Town* t);
	
	/**
		Gets the distance between towns using long and lat from each
		@param double l1
		@param double g1
		@param double l2
		@param double g2
		@return the distance
	*/
	double getDistance(double l1, double g1, double l2, double g2);