void output_result( struct compute *data, char *file_name )
{
double x;
double y;
int i;
FILE* fp;
fp = fopen( file_name, "w" );
for( i = 0; i < 20; i++ ) {
x = data->start_x + ( i * data->step_x );
y = sin( x );
printf( "x= %lf, y= %lf\n", x, y );
fprintf( fp, "x=, %lf, y=, %lf\n", x, y );
}
fclose( fp );
}
start_x とstep_x を使って計算
を行い,結果をファイルに書き込む関数
25