In this case, the only value you can set is false with:
bool* a = new bool[100000]();
However, I'm not sure why you think you cannot use a loop. They are there for a reason. You should use only the prepared fill or fill_n (depending on taste).
A note using new "raw" as this is a terrible programming practice. Use std::vector<bool> *:
std::vector<bool> v; v.resize(100000); std::fill(v.begin(), v.end(), true);
Or:
std::vector<bool> v; v.reserve(100000); std::fill_n(std::back_inserter(v), 100000, true);
* Of course, std::vector<bool> happens to break the corresponding container interface, so it doesn't actually store bool . If std::vector<char> used in this problem.
GManNickG
source share