Boolean array to hold ASCII characters

I need to make a guesses array (like a vector, but without methods) that holds a Boolean for each ASCII character.
I am new to c++ and have no idea on how to proceed. Please help!
Thank you in advance
like a vector, but without methods

Why is this a requirement?
No, it just need to be a bool array that holds ascii characters
it just need to be a bool array that holds ascii characters

An array of bools can not hold ASCII characters.

You can however, index an array of bools by ASCII characters.
1
2
3
  bool guesses[256];  // An array of bools

  guesses['A'] = true;


Don't forget to initialize the array.

An easier approach is to use the bitset container.
1
2
3
4
5
#include <bitset>

  std::bitset<256> guesses;  // Initialized to false by default

  guesses['A'] = true;

http://www.cplusplus.com/reference/bitset/bitset/








Topic archived. No new replies allowed.