c++ - Initializing a string array -


i try initialize string array std::cin can not code :

string *words[6];  (int i=0 ; i<6;i++){         cin >> words[i];    //error } 

can me!!

you don't need create them dynamically:

string words[6];    //notice deleted '*' here (int i=0 ; i<6;i++){     cin >>words[i]; } 

what you've created array of pointers, in every pointer must initalized new before can use , deleted afterwards.


Comments

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -