不知道问题出在哪里...fstream问题
不知道怎样才能把红色字部分的内容写在txt里面
刚学C++...囧
#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
int height, feet, inches, weight;
double BMI;
int main() {
string height, feet, inches, weight, BMI;
ofstrem outfile;
outfile.open("HW.txt");
void promptUser(void);
outfile.setf(ios::fixed,ios::floatfield);
promptUser();
while (BMI > 0) {
if (BMI < 18.5) {
outfile << "Your MBI is " << BMI << ", "
<< "indicating your weight is in the Underweight category\n"
<< "for adults of your height" << endl << endl;
promptUser();
}
if ((BMI >= 18.5) && (BMI < 24.9)) {
outfile << "Your MBI is " << BMI << ", "
<< "indicating your weight is in the Normal category\n"
<< "for adults of your height" << endl << endl;
promptUser();
}
if ((BMI >= 25.0) && (BMI < 29.9)) {
outfile << "Your MBI is " << BMI << ", "
<< "indicating your weight is in the Overweight category\n"
<< "for adults of your height" << endl << endl;
promptUser();
}
if (BMI >= 30.0) {
outfile << "Your MBI is " << BMI << ", "
<< "indicating your weight is in the Obese category\n"
<< "for adults of your height" << endl << endl;
promptUser();
}
}
outfile.close();
system("PAUSE");
return EXIT_SUCCESS;
}
void promptUser() {
cout << "Enter the patient's height"
<< "(in ft and inches-Enter 0 0 to stop): ";
cin >> feet >> inches;
cout << "Enter the patient's weight(in pounds): " ;
cin >> weight;
height = 12 * feet + inches;
cout.precision(1);
BMI = weight * 703 / ( height * height );
outfile << "Height: " << feet << " feet, "
<< inches << " inches" << endl;
outfile << "Weight: " << weight << " pounds" << endl;
}