2017-07-25 5 views
0

私は私のファイルを解決しようとすると、私は次のエラーを取得するには:のmyFile宣言されていない識別子

myFile undeclared identifier 

ヘルプをいただければ幸いです! :)私は本当にこのコードに問題があるのか​​分かりません。 myFile

を宣言するstd::ofstream myFileか、(メイン外)プログラムの開発の先頭にusing namespace std;を追加し、すべてのstd::を削除することができます。

#include "stdafx.h" 
#include <iostream> 
#include <fstream> 
#include <string> 
#include <windows.h> 


int main() 
{ 
    ofstream myFile; 
    std::string name; 
    std::string password; 
    std::cout << "Enter Name" << std::endl; 
    std::cin >> name; 
    std::cout << "Enter password" << std::endl; 
    std::cin >> password; 
    std::string info = name + ":" + password; 
    myFile.open ("Database.txt"); 
    myFile << (info) << std::endl << ; 
    myFile.close(); 
    Sleep(10000); 
} 

答えて

0

あなたが使用することをsould。

あなたが "Database.txt" にテキストを追加したい場合は、使用sould:

myFile.open("Database.txt", ios::app); 

何かが間違っている:

myFile << (info) << std::endl << ; 

あなたが最後<<

を保つsould'nt

あなたのメインに何かを返すこともできます。

関連する問題