I have to create a program that will take a data file named current.txt as an input and the produced output will be saved into another file. I am almost done with the first part however, it's not working. I am not sure if I am opening the file properly. And the second part, I don't even know how to do it. Please please please please, if you guys could help me or even give me a clue. I am really begging at this moment. Please.
There was a given resistance for me to put into an array and I have to use the data file current.txt in my current in order to calculate power.
So the prompt was to redo a program that we did in the past.
The initial prompt was to take 5 "current" inputs from the user then use those numbers to calculate.
This was the program I created:
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
cout << "Welcome! Let us calculate power." <<endl;
cout << "Please provide 5 numerical values for current:" <<endl;
cout << "" <<endl;
This one worked!
This time, instead of asking for user's input, we use a data file that our teacher gave us as the input/ cin <<. He named it as current.txt. So my problem is it's not taking the current.txt input and calculating it! It just waits and I don't know how to solve the problem.
In addition, instead of having the "result" display into the screen, he wants it saved into another file. This one, I am not really sure how to do. PLEASE HELP!
Ok. I would suggest looking up fstream and how to use it. Once you have opened the file, it is quite easy to get the data from it; it is identical to how cin works.
@ terapaht: This is actually common. The OP is probably trying to hide the tracks of getting help on their homework from any school admins that might search for their test questions on forums like these. It's a shame because it ruins the thread for any future searches. 8^{
Might just be an honest misunderstanding from a newbie too. There's really nothing about the help given here that would break any school rules.
I frequent other sites where they limit editing until a member establishes themselves. Other places where many people immediately quote newbie posts so they can't edit the question away.
In any case, hopefully the OP will see these posts and choose to not do it again...