#include #include #include "wtemp.h" #include "wutil.h" /** * Make a print rep of a Temperature struct * @param target -- the string to put the print rep into * @param temp -- a pointer to a Temperature struct * **/ void tempToString(char* target, Temperature* temp) { sprintf(target, "%d %s", temp->temperature, temp->scale); } /** * Constructor for the temperatore struct * @param temp-- the termperature * @param scale -- ie fahrenheit or Celcius * @return a pointer to a Temperature struct * **/ Temperature* makeTemperature(int temp, char *scale) { Temperature* rtn = malloc(sizeof(Temperature)); rtn->scale = strmcopy(scale); rtn->temperature = temp; return rtn; } /** * Temerature destructor. * Frees all memory used in the passed temperature * @param temp the temperature struct to be destroyed * **/ void freeTemperature(Temperature* temp) { free(temp->scale); free(temp); }