C++ char array Working with strings in an array
#include <iostream> int main()//w w w . ja v a 2 s . c om { const int max_str {80}; // Maximum string length including \0 char stars[][max_str] { "AAAAAA", "EEEEEE", "BBBBBB", "FFFFFF", "CCCCCC", "GGGGGG", "DDDDDD", "HHHHHH" }; int choice {}; std::cout << "Pick a lucky star! Enter a number between 1 and " << sizeof(stars)/sizeof(stars[0]) << ": "; std::cin >> choice; if(choice >= 1 && choice <= sizeof stars/sizeof stars[0]) { std::cout << "Your lucky star is " << stars[choice - 1] << std::endl; } else { std::cout << "Sorry, you haven't got a lucky star." << std::endl; } }