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

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

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

asp.net mvc - breakpoint on javascript in CSHTML? -