Hello, I experience a strange problem. I think the fix is obvious but I do not manage to find it
I try to get the content of the file I attached with the following code
[code]#include
#include
#include
#include
#include
using namespace std;
void test() {
ifstream ifile(“test.txt”);
if(!ifile) {
cout << “Problem with test.txt” << endl;
return;
}
string line;
stringstream ss;
string tmp1, tmp2, tmp3, tmp4;
getline(ifile,line);
while(getline(ifile,line)) {
// 4;21/07/2015;15:20:14;111.680779
ss << line;
getline(ss,tmp1,’;’);
getline(ss,tmp2,’;’);
getline(ss,tmp3,’;’);
getline(ss,tmp4,’;’);
cout << tmp1 << " <" << tmp1.c_str() << ">, " << atoi(tmp1.c_str()) << endl;
}
}[/code]
The problem is I get this output
[quote]root [0] .x test.C++
Info in TUnixSystem::ACLiC: creating shared library /home/pamputt/dev/./test_C.so
4 <>, 0
4 <>, 0
4 <>, 0
4 <>, 0
4 <>, 0
4 <>, 0
4 <>, 0[/quote]
That means that the c_str() method returns an empty char string and I do not understand why. Sometyhing worng with my txt file? Any idea?
PS : I get this result on ROOT 6.04/06 on 64-bits linux
test.txt (432 Bytes)