【发布时间】:2016-10-02 07:05:34
【问题描述】:
我的代码有问题,debit.txt的结果和输入的不一样:
long int s;
ofstream outfile;
outfile.open("saldo.txt");
cout << "Masukan jumlah saldo kredit : "; cin >> s;
outfile << s << endl;
outfile.close();
我的saldo.txt
long int db;
ofstream outfile;
outfile.open("debit.txt");
cout << "Masukan jumlah saldo kredit : "; cin >> db;
outfile << db << endl;
outfile.close();
我的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,有人可以帮我解决这个问题吗? :)
【问题讨论】: