C++ char array Initializing pointers for strings
#include <iostream> int main() {// w w w . ja v a 2 s.c om const char* pstar1 {"Java"}; const char* pstar2 {"Oracle"}; const char* pstar3 {"Javascript"}; const char* pstar4 {"CSS"}; const char* pstar5 {"HTML"}; const char* pstar6 {"C"}; const char* pstar7 {"C++"}; const char* pstar8 {"Python"}; const char* pstr {"Your lucky star is "}; int choice {}; std::cout << "Pick a lucky star! Enter a number between 1 and 8: "; std::cin >> choice; switch (choice) { case 1: std::cout << pstr << pstar1 << std::endl; break; case 2: std::cout << pstr << pstar2 << std::endl; break; case 3: std::cout << pstr << pstar3 << std::endl; break; case 4: std::cout << pstr << pstar4 << std::endl; break; case 5: std::cout << pstr << pstar5 << std::endl; break; case 6: std::cout << pstr << pstar6 << std::endl; break; case 7: std::cout << pstr << pstar7 << std::endl; break; case 8: std::cout << pstr << pstar8 << std::endl; break; default: std::cout << "Sorry, you haven't got a lucky star." << std::endl; } }