Hey,
I am using vectors to store read in Data but something screwy is going on. Here is my ReadData Function.
Now I define a file, with 24000 lines and pass those to this function but I am only getting a vector which is size 1 and has data from the first line......am I not using push_back properly?Code:int Data::ReadData(char *name,int lines) { int dumx,dumy,dumz; double dumf1,dumf2,dumf3,dumf4,dumf5,dumf6; FILE *file; printf("Opening File: %s\n",name); file=fopen(name,"r"); // Opens the passed filename if (file==NULL){perror("ERROR: ");return 1;} printf("File Opened Successfully\n"); printf("Writing Data From File To Vectors\n"); for (int k=0;k<lines;k++); { fscanf(file,"%i %i %i %lf %lf %lf %lf %lf %lf",&dumx,&dumy,&dumz,&dumf1,&dumf2,&dumf3,&dumf4,&dumf5,&dumf6); x.push_back(dumx); f1.push_back(dumf1); f2.push_back(dumf2); y.push_back(dumy); f3.push_back(dumf3); f4.push_back(dumf4); z.push_back(dumz); f5.push_back(dumf5); f6.push_back(dumf6); } printf("Data Read Successfully....\n"); // Used to Debug File Read Process..... // for (int i=0; i<x.size(); i++) // { // printf("%i %i %i %lf\n",x.at(i),y.at(i),z.at(i),f1.at(i)); // } setCurrentVect(1); printf("Current Vector Set to 1\n"); fclose(file); printf("File Closed\n"); return 0; }



LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.