simple file
UT_DATE 2011_04_13 s UT date at start of night
TSCOPE 200"_HALE s 200" Hale Telescope at Mt Palomar
simple code
not so simple results
When I run the code using the commented out fscanf, I get a list of all the strings in the file but when I run the code using fgets I get
TSCOPE 200"___04_13 s UT date at start of night
HALE s 200" Hale Telescope at Mt Palomar
UT_DATE 2011_04_13 s UT date at start of night
TSCOPE 200"_HALE s 200" Hale Telescope at Mt Palomar
simple code
Code:
#include <stdio.h>
#include <stdlib.h>
#include "/Users/p1640/1640/C/FITS/include/fitsio.h"
int main (int argc, const char * argv[]) // argv[1] = fits file. argv[2] = header file
{
fitsfile *fptr;
FILE *header;
char *line;
int status;
line = (char *)calloc(60, sizeof(char));
if ((header = fopen(argv[2],"r")) ==NULL)
printf("couldn't open header file\n");
//if (fits_open_file(&fptr, argv[1], READWRITE, &status)) {
// printf("load_simple_fits_float_data: fits_open_file: ", status);
// return (1);
//}
while (fgets(line,60,header))
//while (fscanf(header,"%s",line) != EOF)
{
printf("%s\n",line);
//fscanf(header,"%s",line);
//printf("%s",line);
//fscanf(header,"%s",line);
//printf("%s",line);
//fgets(line,60,header);
//printf("%s\n",line);
}
fclose(header);
return 0;
}
not so simple results
When I run the code using the commented out fscanf, I get a list of all the strings in the file but when I run the code using fgets I get
TSCOPE 200"___04_13 s UT date at start of night
HALE s 200" Hale Telescope at Mt Palomar