2012-04-05 20 views
1

私はC++をかなり新しくしています。プロジェクトをコンパイルしようとすると、Visual Studio 2010 Expressに「can not openファイル: 'ofstream':そのようなファイルやディレクトリはありません」という致命的なエラーが発生しました。私の実装ファイル(ここで、私はエラーを経験しています)、次のとおりです。"Visual Studio 2010 Express Editionでインクルードファイルを開くことができません: 'ofstream'"エラー?

#include "Character.h" 
#include <iostream> 
#include <ofstream> 

using namespace std; 

ofstream characterSave; 

// Sets the character's name to what the user inputted 
void Character::setName(string name) 
{ 
    // Set characterName to equal what user inputted 
    characterName = name; 
} 

// Output the character's name when called 
string Character::getName() 
{ 
    // Return characterName 
    return characterName; 
} 

// Save the user's data to save.dat 
void Character::saveToFile() 
{ 
    // Creates new save file 
    characterSave.open("character.dat"); 

    // Writes character's name to first line of save file 
    characterSave << characterName << endl; 

    // Closes save file 
    characterSave.close(); 
} 

私はオンラインの周りに検索した、と私は、この問題で誰を見つけることができません。それは私のVisual Studio Expressのローカルコピーですか?どんな助けでも大歓迎です。

+0

Google for ['ofstream'](https://www.google.co.uk/search?q=ofstream)、最初の[result](http://www.cplusplus.com/reference/iostream/ofstream /)あなたがヘッダ '' –

答えて

3

あなたはofstreamが宣言されているところだ

#include <fstream> 

を必要としています。

+0

ありがとうございました!最後にそれを働かせました。 –

関連する問題