Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ using fstream

Tags:

c++

fstream

Ok so I haven't used C++ since highschool (used to work in borland C++)

Now I want to solve a problem in C++, yet I don't understand why fstream doesn't work

For some reason ios::in doesn't work.

#include <fstream>
fstream f("Cities.txt,ios::in);

How do I use Fstream properly?

Thanks in advance!

Note : I'm using Visual Studio 2008

like image 457
robertpas Avatar asked Jun 24 '26 22:06

robertpas


1 Answers

change from

fstream f("Cities.txt,ios::in);

to

std::fstream f("Cities.txt" , std::ios::in);
^^^                       ^   ^^^
namespace          you miss"  namespace

done!

like image 149
billz Avatar answered Jun 26 '26 10:06

billz