Code:
#include <iostream.h>
#include <stdlib.h>
#include <string>
#include <fstream>
int main()
{
string filename, line;
cout << "Input filename:";
cin >> filename;
ifstream in(filename.c_str());
filename+=".out";
ofstream out(filename.c_str());
while (in) {
getline(in,line);
while (line[0]==' ') { line.erase(0,1); cerr << line << endl;}
out << line << endl;
cerr << line << endl;
}
in.close();
out.close();
return 0;
}
i own a ti-89 graphing calculator. i want to read the massachusetts drivers manual on there. unfortunately, all text readers only use text (duh...), and don't support pdf files. i've converted the files to txt, but they need to be... pruned... before transferring to my graphing calculator. in particular, there's a lot of leading space. this program is designed to input a text file and output another text file, with another extension, with all of its leading spaces cleaned up. ie:
Code:
This
is
my
manual
now
Code:
This
is
how
i
want
it
to
be
here's the problem: in the loop to remove spaces, the program gets stuck in an infinite loop. i don't know why. it trips on every file i've tried, but the place it trips varies. i've cut and pasted a section of that manual and posted it here. it trips up on this file too, so it's probably some hidden characters i've overlooked. any ideas? thanks in advance