simple question [istream]

Hi,

I am doing first steps in c++.
I have very basic question.
I want to read data from txt file.
I have to use istream.
I received an error:


I am trying to make :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
int main()
{ 
		
   std::istream infile("file.txt");
Error	1	error C2664: 'std::basic_istream<_Elem,_Traits>::basic_istream(std::basic_streambuf<_Elem,_Traits> *,bool)' : cannot convert parameter 1 from 'const char [17]' to 'std::basic_streambuf<_Elem,_Traits> *'	d:\VTK Examples\ReadTXTFile\sources\TextFileReader.cxx	131	TextFileReader

  vtkIdType number_of_points, number_of_triangles;
  infile >> number_of_points >> number_of_triangles;
  vtkSmartPointer<vtkPoints> points
    = vtkSmartPointer<vtkPoints>::New();
  points->SetNumberOfPoints(number_of_points);
  for (vtkIdType i = 0; i < number_of_points; i++)
    {
    double x, y, z;
    infile >> x >> y >> z;
    points->SetPoint(i, x, y, z);
    }
  vtkSmartPointer<vtkCellArray> polys
    = vtkSmartPointer<vtkCellArray>::New();
  for (vtkIdType i = 0; i < number_of_triangles; i++)
    {
    vtkIdType a, b, c;
    infile >> a >> b >> c;
    polys->InsertNextCell(3);
    polys->InsertCellPoint(a);
    polys->InsertCellPoint(b);
    polys->InsertCellPoint(c);
    }
  vtkPolyData * polydata = vtkPolyData::New();
  polydata->SetPoints(points);
  polydata->SetPolys(polys);



	return EXIT_SUCCESS;

}



I would appreciate for any help please.


agatte
Use std::ifstream instead of std::istream.
Thanks very much for help ;)
Topic archived. No new replies allowed.