#include <stdio.h>
#include <stdlib.h>
// --------------------------------------------------------

int main()
{
	FILE *f1, *f2;
	
	if ((f1= fopen("points.txt", "rt")) == NULL) {
		printf("\n *** error of fopen() for read! \n");
		system("pause");
		
		exit(1);
	}
	
	if ((f2= fopen("bbb.txt", "wt")) == NULL) {
		printf("\n *** error of fopen() for write! \n");
		system("pause");
		
		exit(1);
	}
	
	
	printf("\n OK of fopen() \n");
	system("pause");
	// --------------------------------------------------------
	
	double x, y, z;
	int no, ct= -1;
	
	fprintf(f2, "spline\n");
	for (;;) {
		// read a record of data
		no= fscanf(f1, "%lf %lf %lf", &x, &y, &z);
		
		if (no == 3) {
			fprintf(f2, "%.6le,%.6le,%.6le\n", x, y, z);
			ct++;
		}
		
		if (feof(f1)) {
			break;
		}
	}
	// end of data read
	fprintf(f2, "\n\n\n");
	
	printf("\n ct= %d, \n", ct);
	printf("\n %3d, %.6le %.6le %.6le \n", no, x, y, z);
	system("pause");
	return(0);
}// end of main()
