Hi, I'm learning intro to c++.
My question is, how do I input values that come from a different text file so that the program uses those values for calculations?
Basically, it gives me a list of numbers and tells me what the numbers are for... and then I have to integrate them using ifstream.
For example..
Text file:
111
222
333
444
555
666
and each of those lines represent a variable,
a
b
c
d
e
f
(notice the space in between d and e, does it change anything?)
I got so far as to opening the file correctly... but I'm stuck.
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
int main() {
char myFileName[64];
double a = 0;
double b = 0;
double c = 0;
double d = 0;
double e = 0;
double f = 0;
ifstream locationtemp;
cout << "Enter the file name.\n";
cin >> myFileName;
locationtemp.open(myFileName);
if ( locationtemp.fail() )
{
cerr << "\n\nERROR:Unable to open file/File did not open correctly\n";
return(1);
}
btw those arent the real values or variables.
Any help is greatly appreciated. Thanks :)