Hello folks,
I’m having trouble reading ascii text from root on Windows. I’ve tried a couple of macros, one from this thread, with little success. On the other hand, the two codes both work as they should on root under cygwin/Xwindows.
I’m running root 4.00/04 under Windows 2000Pro, with VC++ v6.0 service pack 3.
On the cygwin side, I’m running root 3.10/02, with (a recently updated) cygwin and cygwin/X.
It appears that the problem is that on windows, a call to a “read” type of function, like “get” or TString::ReadLine produces no result, but doesn’t actually fail.
My test codes and output are below. I apologize for the length of what follows. I figured it was better to be as complete as possible.
Thanks for your help.
Brian
Test codes:
The first code is:
void testio() {
char ch;
ifstream testinFile( "testFile.txt", ios::in);
while( !testinFile.eof()) {
testinFile.get( ch);
cout << "char: ";
cout.put( ch);
cout << endl;
}
testinFile.close();
}
On windows, it produces:
whereas on cygwin, it produces:
[quote]
root [0] .L testio.C
root [1] testio()
char: T
char: h
char: i
char: s
char:
char: i
char: s
char:
char: a
char:
char: t
char: e
char: s
char: t
char:
char:
root [2]
[/quote
The second code is:
#include "iostream.h"
#include "TString.h"
void testio2() {
ifstream f;
TString str;
f.open("testFile.txt", ios::in);
cout << "About to check if 'f' is good" << endl;
if (f.good()) {
cout << "About to loop while !eof" << endl;
while(!f.eof()) {
str.ReadLine(f, kFALSE);
cout << str << endl;
cout << "Did a ReadLine" << endl;
}
cout << "Done with 'while'" << endl;
cout << "About to close input" << endl;
f.close();
cout << "Done closing input" << endl;
}
cout << "Done with 'if'" << endl;
}
On windows it produces:
and on cygwin I get:
[quote]
root [2] .L testio2.C
root [3] testio2()
About to check if ‘f’ is good
About to loop while !eof
This is a test
Did a ReadLine
Did a ReadLine
Done with ‘while’
About to close input
Done closing input
Done with ‘if’
[/quote][/quote]