|
From: Paul S. <Ps...@le...> - 2002-03-10 01:23:40
|
Greetings,
Iam trying to complete the tutoils from tinking C++, chapter 2 and seam =
to be having a problem with a for loop couting down.=20
The program is meant to read a file and display it starting with the =
last line of the file, it reads the file ok and copies it to an array =
but when it gets to the for loop it just skips over it,=20
I have tried changing the values in the for statement but the loop is =
still never enterd and it works if the loop counts up from zero to the =
size of the fileCan anyone help?=20
Code listed below:
//Backvector.cpp
//Copy the lines of a file into an array and
// diplay then starting with the last line.
#include <cstdlib>
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
int main(int argc, char *argv[])
{
vector<string> v;
ifstream in("Backvector.cpp");
string line;
while(getline(in, line)) {
v.push_back(line); // Add the line to the end
filesize++; // Get number of lines in file
// Add line numbers:
for(int i =3D filesize; i < 0; i - 1)
cout << i << ": " << v[i] << endl;
system("PAUSE");
return 0;
} ///:~
Thanks for any help
Paul Stone
|