#include <stdio.h>
#define FLOAT 4

main()
{
        int pchfd, newpchfd,pval,j;
	int firstframe,lastframe,nbframe;
	long skipbytes;
#define ARRSIZ 200
	float vals[ARRSIZ]; /* enough for 46 poles + 4 data values */
	char  input[32]; /* orig file containing pitches & amps */
	char  output[32]; /* new file containing pitches & amps */
	char	answer[10];

	fprintf(stderr," Enter name of pitch data input file\t");
	scanf("%s",input);
	if((pchfd = open(input,0)) < 0) {
		fprintf(stderr," Can't open pitch analysis file\n");
		exit(1);
		}
	nbframe = 2*FLOAT; 
again:	fprintf(stderr," Enter first and last frames\t");
	scanf("%d %d",&firstframe,&lastframe);
	if(lastframe < firstframe) {
		printf("pedit: error: last frame less than first.\n");
		exit(1);
		}
	skipbytes = (firstframe) * nbframe;
	if(lseek(pchfd, skipbytes, 0) < 0) {
		printf("error on lseek\n");
		exit(1);
		}
	for(j = firstframe; j <= lastframe; j++) {
		if(read(pchfd, (char *)vals, nbframe) != nbframe) {
			printf(" bad read\n");
			exit(1);
			}	
		fprintf(stderr,
		"%d %6.2f %f\n", 
		j,vals[0],vals[1]);
		}
	goto again;
}

