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
Post a Comment