Bool Array

I have this part in my code...is it correct to do it with a bool array?
1
2
3
4
5
6
7
8
 for(i=0;i<A.size();i++){
          if(Alphabet[i]==false)
                cout<<A[i];
          else if(Alphabet[i]==true){
            cout<<endl;
             cout<<A[i];
            }
      }
The conditionals in your if statements are tautologic. But they are correct. Your program may crash if the array Alphabet is of size less than those of the array A.

1
2
3
4
5
6
7
8
9
10
for (i = 0; i < A.size(); i++)
{
    if (! Alphabet[i])
        cout << A[i];
    else
    {
        cout << endl;
        cout << A[i];
    }
}
Topic archived. No new replies allowed.