sahiilseth 0 Newbie Poster

Hi,
I have been trying to read the data from a file, which looks like this, for some hundred rows:
y x1 x2 x3 x4 x5
-1.120448885 1 0.333799767 0.488337281 -2.011297473 -0.097103584
1.981332002 1 -0.559282628 -0.775806971 1.739534174 -0.900925792
5.955490161 1 1.618560385 0.242730629 1.008987835 -1.092595567

here is the code I am using:

int len;
fscanf(fpIn, "%s\t%s\t%s\t%s\t%s\t%s\n", stry,str1,str2,str3,str4,str5);
printf("%s\t%s\t%s\t%s\t%s\t%s\n", stry,str1,str2,str3,str4,str5);
while(fgets(strLine, LINE_LENGTH, fpIn) != NULL){
		sscanf(strLine, "%lf\t%lf\t%lf\t%lf\t%lf\t%lf", &y,&x1,&x2,&x3,&x4,&x5);
		printf("%f\t%f\t%f\t%f\t%f\t%lf\n",y,x1,x2,x3,x4,x5);
}

but its reading in a undesired manner:
y x1 x2 x3 x4 x5
-1.120449 1.000000 0.333800 0.488337 -2.011297 0.000000
73.000000 -0.097104 0.333800 0.488337 -2.011297 0.000000

I am trying several things, like chopping of a the last char in the string before doing scanf, but that somehow didnt work.


but it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.