function double_c_write ( output_filename, x, y, c )

%*****************************************************************************80
%
%% double_c_write() writes double C data to a file.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    19 April 2011
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    string OUTPUT_FILENAME, the output filename.
%
%    real X(N), Y(N), the coordinates of the data points.
%
%    integer C(N), is 1 or 2, depending on which set the corresponding
%    data point belongs to.
%

%
%  Open the file.
%
  output_unit = fopen ( output_filename, 'wt' );

  if ( output_unit < 0 ) 
    fprintf ( 1, '\n' );
    fprintf ( 1, 'DOUBLE_C_WRITE - Error!\n' );
    fprintf ( 1, '  Could not open the output file.\n' );
    error ( 'DOUBLE_C_WRITE - Error!' );
  end
%
%  Write the data.
%
  n = length ( x );

  for i = 1 : n
    fprintf ( output_unit, '  %10.4f  %10.4f  %d\n', x(i), y(i), c(i) );
  end
%
%  Close the file.
%
  fclose ( output_unit );

  return
end
