Calculating total number of adjacent integers
<p>I want to calculate the number of integers excluding repeats line by line from the file. </p>

<p>The output I desire is:</p>

<pre><code>Duplicates : 9
Duplicates : 4
Duplicates : 5
Duplicates : 5
Duplicates : 1
Duplicates : 1
Duplicates : 8
</code></pre>

<p>For further explanation of the concept:
Take the second line of the file:</p>

<pre><code>1 2 3 4 5 6 5 4 5
</code></pre>

<p>At this line there is a 1 so increment the counter because 1 was found first.
Next comes a 2, 2 is not 1 so increment the counter. Next comes a 3, 3 is not a 2 so increment the counter. Next comes a 4, 4 is not a 3 so increment the counter. Next comes a 5, 5 is not a 4 so increment the counter. Next comes a 6, 6 is not a 5 so increment the counter. Next comes a 5, 5 is not a 6 so increment the counter. Next comes a 4, 4 is not a 5 so increment the counter. Next comes a 5, 5 is not a 4 so increment the counter. The number of integers excluding repeats is 9.</p>

<p>Another example:
Take a look a line 8 of the file:</p>

<pre><code>34 34 34 34 34
</code></pre>

<p>At this line there is a 34 so increment the counter. Next comes a 34, 34 is 34 so do not increment the counter. Next comes 34, 34 is 34 so do not increment the counter. Next comes a 34, 34 is 34 so do not increment the counter. Next comes a 34, 34 is 34 so do not increment the counter. The number of integers excluding repeats is 1.</p>

<p>EDIT:
I took the suggestion of a user on here and looked at a few link related to adjacent strings and integers. The output is almost completely correct now when compared to the desired output that I listed above. I will only put the pertain code below:</p>

<p>Output:</p>

<pre><code>check1:1
check1:1
check1:2
Duplicates : 6   (Wrong value)
check1:2
Duplicates : 5   (Wrong value)
Duplicates : 5
Duplicates : 5
check1:0
check1:0
check1:0
check1:0
Duplicates : 1
Duplicates : 1
check1:0
check1:0
check1:2
check1:3
check1:3
check1:3
check1:4
check1:5
check1:5
check1:5
check1:5
check1:6
check1:6
Duplicates : 7  (Wrong value)
</code></pre>

<p>From the output it appears that whenever a test case goes through the if statement <code>if(array[check] == ch)</code>, the output is incorrect. </p>

<p>I have been staring at the loops in this function for a long and I am still stumped. 
Any suggestions as to why that loop is leading to incorrect values? Thank you.</p>