I am having trouble on figuring out how to read each line from a txt file into a decimal variable, the only argument that works for what I'm doing is char.
Here's the instructions for my HW.
Here's the txt file.
I actually need help for all of the steps but I'm stuck with reading each line into a decimal variable.
Here's my current code.
#include <iostream> // standard console i/o
#include <string> // string library
#include <iomanip> // output formatting
using namespace std; // standard namespaces
ifstream inFile; // handle to input file
string strFileName = // file name
char cChar; // character read from file
string strFileData; // data read from file
string strTotal = // output of total value
"Total value: %.4f";
inFile.open(strFileName); // open the input file
if (inFile.is_open()) // did the file open
inFile.get(cChar); // get the first char of the file
while (!inFile.eof()) // while not end of file
cout << cChar; // display the character
inFile.get(cChar); // get the next character
inFile.close(); // close the file
printf("File %s not found. \n", strFileName.c_str()); // file not found error message
cout << endl << endl; // blank line
system("Pause"); // pause before closing
If you check the instructions in the link above you will see that the console does not display the txt file, but I also don't know how to read it without displaying it. I've experimented with removing cout in my while section but I don't think that it works and the only thing that runs is my blank line and system pause at the end. Please help. (No programming experience at all)