C++ char array of pointers
#include <iostream> int main()/*w w w. ja v a2 s .com*/ { const char* pstars[] { "Java", "HTML", "C++", "CSS", "C#", "Python", "Javascript", "Ruby" }; int choice {}; std::cout << "Pick a lucky star! Enter a number between 1 and " << sizeof(pstars) / sizeof(pstars[0]) << ": "; std::cin >> choice; if (choice >=1 && choice <= sizeof(pstars)/(sizeof pstars[0])) { std::cout << "Your lucky star is " << pstars[choice - 1] << std::endl; } else { std::cout << "Sorry, you haven't got a lucky star." << std::endl; } }