extracting numbers using ifstream
Please forgive me if this is a stupid question . . . I am a new programmer and I've read through a "C++ For Beginners" book, but I'm obviously not an expert.
I'm trying to write a program that will: 1) access my file that has data in it, 2) extract the numbers that I need from this file, and 3) put the numbers into a column in another file. I've tried to follow examples in my C++ book to do this, but it just seems like it should be more simple than what I've done:
ifstream input("betalogfile",ios::binary | ios::in);
int l = 0;
double pos4 = 782; // this number is the cursor position in my file of the first "digit" of the first number that I need to extract
i = 0;
input.seekg((pos4 + i),ios::beg);
input >> lambda[i][l];
output << lambda[i][l];
}while(i<12); // the numbers I want to extract is 11 digits long
output << "\n";
pos4 = pos4 + 1432; // this number adds on the number of spaces from the first "digit" of the previous number to the first "digit" of the next number I need.
l++; }while(l<N); // N is the number of numbers I need to extract and put into a column
This outputs all of the numbers I need to a column in a separate file. The problem is, that I need to add other numbers to these numbers and treat them as numbers, but I don't know how to extract the numbers more than one digit at a time. Is there a way to do that? Thank you for reading this and especially if you can answer (or understand) my questions.
You have to specify the numbers
Is there any algo that u are going to use to specify the number or are u going to calculate as soon as you get from the file. Can you please Attach the data file and be more specific about what u need. Sorry but i don't see where u are getting at....