The following sequence of routine calls illustrate a simple example of writing a new FITS file:
1. Create the new file with fits_create_file / ffinit. 2. Write the required primary keywords with fits_create_img / ffcrim. 3. Write any additional keywords with fits_write_key / ffpky. 4. Write the primary array data, if any, with fits_write_img / ffppr. 5. Create another extension, if desired, with fits_create_img / ffcrim or fits_create_tbl / ffcrtb. 6. Write any additional keywords with fits_write_key / ffpky. 7. Write data to table columns with fits_write_col /ffpcl. 8. Repeat steps 5 - 7 for any more extensions. 9. Close the fits file with fits_close_file / ffclos.Note that the application program must not explicitly write the required 'END' keyword at the end of each header; the CFITSIO interface will automatically append the END record whenever the header is closed. As a standard practice, users should always read back any FITS files that they have created to ensure that the header values and data structure are correct and self-consistent.