本文介绍了使用fstream的C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,所以我从高中就没用过C ++(以前在borland C ++中工作)

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

现在我想解决C ++中的问题,但我不明白为什么fstream无法正常工作

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

出于某种原因,ios :: in无法正常工作.

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

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

如何正确使用Fstream?

How do I use Fstream properly?

提前谢谢!

注意:我正在使用Visual Studio 2008

Note : I'm using Visual Studio 2008

推荐答案

更改自

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

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

完成!

这篇关于使用fstream的C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 01:08
查看更多