Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9036929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:07:28+00:00 2026-06-16T09:07:28+00:00

Say i have an array char myArrray[5] = {‘T’,’T’,’T’,’T’,’T’} And i want to check

  • 0

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') ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T09:07:29+00:00Added an answer on June 16, 2026 at 9:07 am

    Seems to work fine.

       char myArray[5] = {'T','T','T','T','T'};
        int lineInputs=1;
        for(int k = 0; k < lineInputs; k++)
        {
          int counter=0;
          cout << (k+1) << " ";
          int arrayElements=5;
          for(int u=0; u<(arrayElements-2); u++)
          {
             //cout << myArray[u];
             if(myArray[u] == 'T' && myArray[u+1] == 'T' && myArray[u+2] == 'T')
             {
                 counter++;
                 cout << counter << " ";
             }
          }
        }
    

    Output I get is:

    1 1 2 3 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a char *example that contains 20 chars. I want to
Lets say I have a char array that contains the sequences of chars: robots
Let's say I have an array : char[] chars={'X','X','m','a','t','t','X','X'}; I want to create String
Say I have an array of table DDL queries and I want to get
Say I have an array of key/value pairs in PHP: array( 'foo' => 'bar',
Say I have an array of arbitrary size holding single characters. I want to
Lets say i have the following cstring char array[1000]; How i can convert it
say I have the following code: char[5][5] array; for(int i =0; i < 5;
I have a header file, wich contain a unsigned char array that is in
Suppose i have array of characters. say char x[100] Now, i take input from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.