How to assign string pointer value to elements of a vector using loops in C++

word is a string. A string is composed of chars. You cannot store a string in a string. You need to store a char in a string. For example

word[0] = 'a' 

is legal, while

word[0] = some_other_string 

is not.

Also you cannot initialize a variable with its own value as you did in line 1 of main()

Leave a Comment