Thanks for that Elysia.. I am happy to hear that. I will ofcourse keep send you questions. I really appreciate it. Dont worry :P
I have been sitting with a problem for 20 hours myself searching on the internet and thinking about a solution but cant solve this. I beleive that what I want to do is a bit special, perheps there are functions/syntax to help this problem out.
Actually it is 2 things/questions that is happening at the same time.
But I will start out with the first question to see if the first thing could be solved to not make it to difficult.
.................................................. .................................................. ..........................................
Here we go
What I want to do now as I can scan a file and find the lowest value for example "Low" for the entire file. As the example below with 4 lines that contains 2 different dates. I want to store the Lowest Value of Low for each date into a variable. The two variables I have named: "IntraLow9" and "IntraLow8".
01/12/2006,2005,16.19,16.20,16.19,16.19,2100,16.19
01/12/2006,2006,16.20,16.20,16.20,16.20,200,16.20
01/13/2006,2005,16.20,16.20,16.18,16.20,1700,16.18
01/13/2006,2006,16.18,16.19,16.12,16.19,1500,16.19
As the code is scanning the file from the top to bottom I have managed to do a code that do a count when a new date occurs.(´Perheps´ this will be of help for the solution)
The variable is called: "DateCount" and counts down from 11. This meen when the first date happens in the file it will have a count of 9 and for the other date 8.
So the first key for the first date is 9 then. What I want to do now is to store the lowest value of Low into the variable called: IntraLow9
I know that my approach: (IntraLow + DateCount) is wrong but perheps you understand what I am ´trying´ to do. (It is kind of "Intelligent" assignment to variables)
How could it be possible to do something like this ? (Hope you can understand my explanation of the problem )
Code:
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
int main ()
{
std::string Date;
std::string DateDummy;
double DateCount = 11;
double IntraLow9 = 1000;
double IntraLow8 = 1000;
char Comma;
int Time = 0;
double Open = 0;
double High = 0;
double Low = 0;
double Close = 0;
int Volume = 0;
double IntraHigh = 0;
double IntraLow = 1000;
double IntraVolume = 0;
ofstream Test;
Test.open ("file2.txt");
ifstream myfile ("CCE.txt");
ifstream file0 ("file0.txt");
while ( getline(myfile, Date, ',') )
{
myfile >> Time; // 2111
myfile >> Comma;
myfile >> Open; // 35.23
myfile >> Comma;
myfile >> High; // 35.23
myfile >> Comma;
myfile >> Low; // 35.20
myfile >> Comma;
myfile >> Close; // 35.22
myfile >> Comma;
myfile >> Volume; // 15600
myfile >> Comma;
myfile >> Close; // 35.22
myfile.get(); // read in trailing newline character
if ((Low < (IntraLow + DateCount)) && (DateCount != 11) && (Date == DateDummy)) // I am trying to make the code understand
{ // that (IntraLow + DateCount) meens: IntraLow9 where DateCount
(IntraLow + DateCount) = Low; // for the moment is 9 and then put the lowest value for the
} // date into double IntraLow9.
//////////////////////////////////////////////////////////////////////
if (Date != DateDummy)
{
DateDummy = Date;
DateCount = (DateCount - 1); // DateCount has a CountDown for the Dates ´while´ the code is running. Starting at 11
}
//////////////////////////////////////////////////////////////////////
} // End of While Statement
Test << IntraLow9 <<"\n";
return 0;
} // int main braces