From $ROOTSYS/tutorials/fitsio/FITS_tutorial6.C

// Open a FITS file whose primary array represents
// a spectrum table (flux vs wavelength) and dump its columns
void FITS_tutorial6()
{
   TVectorD *v;
   
   printf("\n\n--------------------------------\n");
   printf("WELCOME TO FITS tutorial #6 !!!!\n");
   printf("--------------------------------\n");
   printf("We are going to open a table from a FITS file\n");
   printf("and dump its columns.\n\n");
  
   TString dir = gSystem->DirName(__FILE__);

   //Open the table
   TFITSHDU *hdu = new TFITSHDU(dir+"/sample4.fits[1]");
   if (hdu == 0) {
      printf("ERROR: could not access the HDU\n"); return;
   }
   
   //Show columns
   Int_t nColumns = hdu->GetTabNColumns();
   printf("The table has %d columns:\n", nColumns);
   for (Int_t i = 0; i < nColumns; i++) {
      printf("...Column %d: %s\n", i, hdu->GetColumnName(i).Data());
   }
   puts("");
  
   delete hdu;
}

 
 FITS_tutorial6.C:1
 FITS_tutorial6.C:2
 FITS_tutorial6.C:3
 FITS_tutorial6.C:4
 FITS_tutorial6.C:5
 FITS_tutorial6.C:6
 FITS_tutorial6.C:7
 FITS_tutorial6.C:8
 FITS_tutorial6.C:9
 FITS_tutorial6.C:10
 FITS_tutorial6.C:11
 FITS_tutorial6.C:12
 FITS_tutorial6.C:13
 FITS_tutorial6.C:14
 FITS_tutorial6.C:15
 FITS_tutorial6.C:16
 FITS_tutorial6.C:17
 FITS_tutorial6.C:18
 FITS_tutorial6.C:19
 FITS_tutorial6.C:20
 FITS_tutorial6.C:21
 FITS_tutorial6.C:22
 FITS_tutorial6.C:23
 FITS_tutorial6.C:24
 FITS_tutorial6.C:25
 FITS_tutorial6.C:26
 FITS_tutorial6.C:27
 FITS_tutorial6.C:28
 FITS_tutorial6.C:29
 FITS_tutorial6.C:30
 FITS_tutorial6.C:31
 FITS_tutorial6.C:32
 FITS_tutorial6.C:33