我找不到错误

I can't find the errors

本文关键字:错误 找不到      更新时间:2023-10-16

编写一个程序,要求用户输入五个浮点数。程序应该创建一个文件并将所有五个数字保存到(即写入)到文件中。

请问任何人都可以说出这里的错误是什么?

#include <iosream>
#include <fstream>
#include <StdAfx.h>
using namespace std;
int main()
{
    float n1,n2,n3,n4,n5;
    ofstream numbersfile;
    numbersfile.open("C:\x\numbers.txt");
    cout<<"enter 5 numbres (will be stored to numbersfile)"<<endl;
    cin>>n1 >>n2 >>n3 >> n4 >>n5;
    xfile<<n1 <<n2 <<n3 <<n4 <<n5 <<endl;
    cout<<" your numbers have been written to numbersfile";
    numbersfile.close();
    return 0;
}
#include <iosream>

拼写错误。应改为

 #include <iostream>

XFILE 从未声明

 xfile<<n1 <<n2 <<n3 <<n4 <<n5 <<endl;

应该是

numbersfile<<n1 <<n2 <<n3 <<n4 <<n5 <<endl;