I am currently working on a program that sets the index's of the "used" array to true or false depending on if there are characters in the "word" array.
#include <iostream>
int main(){
const int SIZE = 5;
char word[SIZE] = {'H', 'e', 'l', '\0', '\0'};
bool used[SIZE];
cout << "word: ";
for (int i = 0; i < SIZE; i++)
{
cout << " " << word[i];
}
cout << endl << endl;
for (int i = 0; i < SIZE; i++)
{
if (word[i] != '\0')
used[i] = true;
else
used[i] = false;
}
cout << "used: ";
for (int i = 0; i < SIZE; i++)
{
cout << " " << used[i];
}
return 0;
}
Output
word: H e l
used: 1 1 1 0 0
My question is, can you store 'true' or 'false' in an array opposed to 1's and 0's?