My 'Count' aint working...:-(
I have some data in a txt file, that I read into an array. Then I want to iterate through the array, counting the number of occurances EACH value has; eg if the value 50 occurs 6 times in the txtx file, the variable count 'should show this. As each value has been counted, I want to plot that value on a chart, count then set back to zero, the next value counted, plotted etc... ( but that is imaterial for now...).....I have a loop in a loop, and its getting messy...I can prove that the values from the txt files are correctly being read into the array, but the im doing something wrong with the loop, as Count always shows 100, the total number of values in the txt file....anyway, here's the code, and any help would be appreciated:
Code:
ifstream InFile;
int Index;
InFile.open("TMAData1.dat") ;
for( Index = 0; Index < 100; Index = Index + 1 ) //enter loop
{
InFile >> Store1[Index] >> ws ;
};
InFile.close();
int x, n;
int Count;
for ( x=0; x<100; x++)
{ Count = 0;
for ( n=0; n<100; n++)
{
if (Store1[x] == Store1[n])
{
Count++; Store1[n] = 0;
}
else{}
/*the plot for each iteration will be done here */ }
}
}