11.07.2014 Views

Flute acoustics: measurement, modelling and design - School of ...

Flute acoustics: measurement, modelling and design - School of ...

Flute acoustics: measurement, modelling and design - School of ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

298 APPENDIX B. PROGRAM LISTINGS<br />

/*<br />

Point.h<br />

By Andrew Botros, 2001-2004<br />

Listing B.24: Point.c<br />

A data point ADT.<br />

*/<br />

#include <br />

#include <br />

#include <br />

#include "Point.h"<br />

void printPoint(Point p) {<br />

printf("(%.2f,%.2f)", p->x, p->y);<br />

return;<br />

}<br />

void printImpedancePoint(Point p) {<br />

printf("%.2f\t%.2f\n", p->x, p->y);<br />

return;<br />

}<br />

Point parseImpedancePoint(char* line, int series) {<br />

Point p = (Point)malloc(size<strong>of</strong>(*p));<br />

char* delimiters = " \t";<br />

char* token;<br />

int n;<br />

/* Parse x value */<br />

token = strtok(line, delimiters);<br />

if(token != NULL)<br />

p->x = at<strong>of</strong>(token);<br />

else<br />

return NULL;<br />

/* Parse y value */<br />

for (n = 0; n < series; n++)<br />

token = strtok(NULL, delimiters);<br />

if(token != NULL && token != "\n") {<br />

p->y = at<strong>of</strong>(token);<br />

}<br />

else<br />

return NULL;<br />

return p;<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!