C++ examples for Data Type:Array Pointer
Using an array of pointers
#include <iostream> int main()// w ww . ja v a 2 s . c om { 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; } }