basic file writing and reading help needed

So i have an assignment in which i need to write a program that takes 5 float numbers and creates a file / saves the numbers to the file and then have this file opened and display the sum of the five numbers, here is what i have but for some reason im getting a runtime error, any help would be greatly appreciated as i am a beginner:

#include <iostream>
#include <fstream>
using namespace std;

int main()

{
float num1, num2, num3, num4, num5;
ofstream outputFile;
ifstream inputFile;
outputFile.open("test.text");

cin >> "Enter first number " >> num1 >> "Enter second number " >> num2
>> "Enter third number " >> num3 >> "Enter fourth number " >> num4 >>
"Enter fifth number " >> num5;


outputFile << num1 << " " << num2 << " " << num3 << " " << num4 << " " << num5;
outputFile.close();

inputFile.open("test.txt");
inputFile >> num1, num2, num3, num4, num5;
cout << "Five numbers added: " << num1 + num2 + num3 + num4 + num5;
inputFile.close();

return 0;
}
1
2
3
4
5
6
7
8
9
10
cout << "Enter first number ";
cin >> num1;
cout << "Enter second number ";
cin >> num2;
cout << "Enter third number ";
cin >> num3;
cout << "Enter fourth number ";
cin >> num4;
cout << "Enter fifth number ";
cin >> num5;


std::cin cannot place data into const cstrings! You need to change the std::cin>> line into the above code.
ah that makes sense, thanks a bunch!
Topic archived. No new replies allowed.