Say i have an array char myArrray[5] = {'T','T','T','T','T'} And i want to check how many instances of 3 pairs of T i have.
I have a forloop below that checks for all 3 instances of T. There should be 3 instances, but for some reason its not even entering the if statement that checks it.
Maybe im just lost im really sleepy.
There are 3 isntances of TTT throughout the array. Thats what we have to get the number 3 in the counter but we arent getting it. (T{T[T)T}T]
full code here: http://ideone.com/AWyOkH
Any ideas?
for(int k = 0; k < lineInputs; k++)
{
int counter=0;
cout << (k+1) << " ";
for(int u=0; u<arrayElements; u++)
{
//cout << myArray[u];
if(myArray[u] == 'T' && myArray[u+1] == 'T' && myArray[u+2] == 'T')
{
counter++;
cout << counter << " ";
}
}
}
Does the issue lay with if(myArray[u] == 'T' && myArray[u+1] == 'T' && myArray[u+2] == 'T') ?
Seems to work fine.
Output I get is: