part lines from file into an array
From: Edo (eddod_at_eddododod.dod)
Date: 09/30/04
- Next message: B. v Ingen Schenau: "Re: [C++] Templates and inheritance"
- Previous message: Alwyn: "Re: Why is C still being used instead of C++"
- Next in thread: Jerry Coffin: "Re: part lines from file into an array"
- Reply: Jerry Coffin: "Re: part lines from file into an array"
- Reply: Karl Heinz Buchegger: "Re: part lines from file into an array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 30 Sep 2004 03:09:40 -0700
Hello
I have a .txt file with <space>-delimited data on each line.
Number of <space>s is 11 so there is 12 <double> numbers in each line.
I need to get from the 2nd to the 11th number into an double array[10],
I did this code below but I must be screwing up something because the
second while condition never evaluates to true.
ifstream fin("path-to-file");
unsigned ling id;
double xyz[10];
double x;
string line;
while( getline(fin, line) ){
istringstream is;
is >> line;
int i = 0;
while( is >> x ){
id = static_cast<unsigned long> (x);
++i;
if( i==1 && i <= 10 ){ xyz[i-1] = x; }
}
is.clear();
if(! fin.good() ) continue;
}
Thanks
- Next message: B. v Ingen Schenau: "Re: [C++] Templates and inheritance"
- Previous message: Alwyn: "Re: Why is C still being used instead of C++"
- Next in thread: Jerry Coffin: "Re: part lines from file into an array"
- Reply: Jerry Coffin: "Re: part lines from file into an array"
- Reply: Karl Heinz Buchegger: "Re: part lines from file into an array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]