I have a code snippet, where I want to read columnar data from a txt file. However, whenever I do so, a large number - namely - -1.073742e+008 gets appended to the beginning of the file. I do not know where it is coming from or how to get rid of it. Since this snippet is part of a larger program that is meant to read the file automatically and pass it to another application, manual deletion is not an option. My code as it currently stands is as follows.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
void main()
{
FILE * fout;
int n;
float f1;
float f2;
float f3;
float npx[5208];
float npy[5208];
float npz[5208];
int v1;
int i;
/*read node cordinates fron the file */
/*char buffer[100];*/
fout = fopen("z1_115k.out", "r");
/*fgets(buffer,100,fout);*/ /* skip the first line*/
while(feof(fout)==0)
{
fscanf(fout, "%d %e %e %e\n", &v1, &f1, &f2, &f3);
npx[v1]=f1;
npy[v1]=f2;
npz[v1]=f3;
}
fclose(fout);
fout = fopen("writeout9.txt" , "w");
for(i=0;i<5208;i++)
{
fprintf(fout, "%e",npy[i]);
fprintf(fout, "\n");
}
fclose(fout);
getch();
}
The file I'm trying to read looks like this
1 -1.998999214E-04 -6.326398761E-06 7.987323916E-04
2 -1.993482729E-04 1.613270797E-05 8.020100649E-04
3 -1.998304651E-04 8.233274457E-06 7.735857507E-04
4 -9.247181879E-05 1.772655523E-04 6.779084215E-04
5 -7.928538980E-05 1.833699498E-04 6.915458362E-04
6 -9.789415344E-05 1.918512862E-04 6.868232158E-04
7 -1.943270909E-04 -4.729676220E-05 8.172317175E-04
8 -1.892633736E-04 -6.464808394E-05 8.175745024E-04
And the output I get for the first column is the following
-1.073742e+008
-1.998999e-004
-1.993483e-004
-1.998305e-004
-9.247182e-005
-7.928539e-005
-9.789415e-005
-1.943271e-004
-1.892634e-004
Why am I getting the -1.073e+08 value at the beginning?