2016-10-02 12 views
-1

結果と同じではありません、debit.txtの結果は、入力と同じではありません私debit.txt入力した番号が、私は私のコードに問題がある

long int s, db; 

    ifstream infile; 
    infile.open("saldo.txt"); 
    infile >> s; 
    cout << s << endl; 

    infile.open("debit.txt"); 
    infile >> db; 
    cout << db << endl; 
    infile.close(); 

} 

と、この結果cek.txt

debit.txtで150を入力しようとすると、結果は乱数になりますが、saldo.txtではなく、誰かがこれを解決するのに役立つのですか? :)

答えて

0

"infile"オブジェクトを閉じずに、 "debit.txt"を開きます。 以下のように小児喘息を閉鎖してください

long int s, db; 

ifstream infile; 
infile.open("saldo.txt"); 
infile >> s; 
cout << s << endl; 


infile.close(); //close here. 


infile.open("debit.txt"); 
infile >> db; 
cout << db << endl; 
infile.close(); 
+2

ahahaありがとうございました!私はそれを忘れた –

関連する問題