The current input in the text file is:
IBM 100 93.2 98.6
MER 200 67.2 43.89
QQQ 300 78.9 70.0
C 200 35.78 50.02
CSCO 400 45.67 57.23
From left to right it's stock name, number of shares, price bought at and current price.
Is it correct to read each row like this..? I've no idea how to do it. I need to somehow use the data from the text and use it to find the profit gain/loss.
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
int numrec; //Given
string stockName[50]; //Given
double numShares[50], buyPrice[50], currPrice[50], pctPL[50],dlrPL[50]; //Given
Does it work? Are you getting expected output at runtime?
Okay, obviosly you don't have any output yet. It looks like you're reading the file correctly.
Why do you have ofstream outFile? Are you going to use an output file later, and just haven't gotten to it yet?
Why do you have ofstream outFile? Are you going to use an output file later, and just haven't gotten to it yet?
Yeah, I haven't gotten to the output yet. I was wondering if I was doing the input right because when I tried doing cout<<inFile<<endl; nothing happens.
Trying to get the output to look something like this, but I have to get the values from input to work first. Any suggestions?