#include <iostream>
#include <cstring>
#include <vector>
usingnamespace std;
int main() {
char *words[]={"stately", "plump", "buck", "mulligan"};/* words is array of pointers to
c_string, words is the very beginning pointer of the array */
size_t words_size =sizeof(words)/sizeof(char *);/* sizeof(words) will give the size of the array,
which is 4, right? sizeof(char *) will give what result? each word in words are different size string!
And what is this words_size? */
vector<string> words2(words, words+words_size); /*because I don't understand words_size,
so I don't understand this expression either! */
for(vector<string>::iterator it=words2.begin(); it<words2.end(); it++) {
cout<<*it<<endl;
}
return 0;
}
This program will output
1 2 3 4
stately
plump
buck
mulligan
to the screen
My question are in the code comments, please , someone explain this for me! Thanks.