C++的有关strcpy_s函数的一些问题

#include
#include
#include
using namespace std;
int main(){
vector strvec;
string str;
cout << "please enter some string,Ctrl+Z to end:" << endl;
while (cin >> str)
strvec.push_back(str);
for (vector::iterator it = strvec.begin(); it != strvec.end(); it++)
cout << *it << endl;

//创建字符指针数组
char **strpoi = new char*[strvec.size()];

//处理指针数组
size_t ix = 0;
for (vector<string>::iterator iter = strvec.begin(); iter != strvec.end(); ++iter, ++ix)
{
    char *p = new char[(*iter).size()+1];
    strcpy_s(p,(*iter).c_str());
    strpoi[ix] = p;
    cout << *p << endl;
    cout << strpoi[ix] << endl;
}
for (size_t j = 0; j < strvec.size(); j++)
    delete[] strpoi[j];
delete[]strpoi;
system("pause");
return 0;

}


为什么这段代码出现错误。
strcpy_s(p,(*iter).c_str());
strpoi[ix] = p;
这句里出错了
图片说明

这个应该怎么改才不会出错呢?求大神指点

这个应该怎么改才不会出错呢?求大神指点

看不懂C,帮顶,,,,

 strcpy_s(p,(*iter).size()+1,(*iter).c_str());

strcpy_s需要三个参数,中间一个是复制元素的大小。

strcpy_s需要三个参数