ok heres something new happening , it seems to work now but with unexpected numbers
inside my txt file is this :
(4,3,-2) (-3,-4,3) (-5,4,10)
(2,3,9) (-4,7,-1) (-1,8,8)
(-6,-10,-1) (-2,2,-2) (-2,10,-5)
main :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
void read(){
fstream myfile2;
myfile2.open ("input.txt");
vector<double> v1,v2,v3;
//char v1,v2,v3;
if (!myfile2.is_open())
cerr <<"Failed to open file";
else{
while (!myfile2.eof()){
for(int i=0;i<=2;i++){
myfile2.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
myfile2 >>v1 >>v2 >>v3;
cout<< v1 <<v2<<v3<<endl ;
}
}
}
| |
operator overload:
1 2 3 4 5 6 7 8 9 10 11 12
|
template <class T>
istream& operator>>(istream& in, vector<T>& vec){
in.ignore(1);
in>> vec.x;
in.ignore(1);
in>>vec.y;
in.ignore(1);
in>>vec.z;
in.ignore(1);
return in;
}
| |
this is what i am getting on the screen:
(4,3,-2)(-9.25596e+061,-9.25596e+061,-9.25596e+061)(-9.25596e+061,-9.25596e+061,
-9.25596e+061)
the first vector is there the other two it seems like its reading something else