So, i have a file with a lot of information and then colums of number wich is what i'm intersted in, something like this:
# =================================================================
# Converted from FITS by "sloan_fitsfile" (Version 2.05)
#
# SDSS Original File = spSpec-51602-0266-022.fit
#
# COLUMN_1 = Lambda (wavelength in Angstrons)
# COLUMN_2 = Flux (in erg/cm2/s/Angstron)
# COLUMN_3 = Error in Flux (in erg/cm2/s/Angstron)
#
# Lambda was corrected by redshift (z) = YES
#
# Some SDSS Parameters:
# Z = -3.6275500000000E-05
# Z_ERR = 2.08542000000000E-04
# Z_CONF = 9.98200000000000E-01
#
# COEFF0 = 3.57850000000000E+00
# COEFF1 = 1.00000000000000E-04
#
# DATE-OBS = '2000-02-28'
# TAIHMS = '06:08:33.65'
#
# RA = 145.89219
# DEC = 0.059372
# EQUINOX = 2000.00
# ==================================================================
3788.9227825527696 9.340889739990234e-16 9.026130676269532e-17
3789.7953147146545 9.33772964477539e-16 9.026130676269532e-17
3790.668047807623 9.33458023071289e-16 9.026130676269532e-17...
So i wrote some lines to jump the information i dont need.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#include <stdio.h>
#define N 4000
main()
{
int i;
signed char x[N][1000];
double a[N], b[N], c[N];
FILE *ArquivoEntrada;
ArquivoEntrada = fopen("spSpec-51602-0266-029.spc1", "r");
i=0;
do{
fgets (x[i] , 1000 , ArquivoEntrada);
printf("i=%d %s\n", i, x[i]);
if(i==26)
{
sscanf (x[i],"%lf %lf %lf",&a[i],&b[i],&c[i]);
printf("i=%d %lf %lf %lf\n", i, a[i], b[i], c[i]);
}
i++;
}while( i<27 );
fclose(ArquivoEntrada);
}
|
So, as you can see, im only testing from line 26 wich is when de colum number's start, i want to read the string x[i] and separate it in 3 arrays (a[i], b[i], and c[i]) but when i print it only a[i] gets the number, b[i] and c[i] print as = 0,00000.
Sorry for my bad english, appreciate any help.