询问者
strcpy(str, "hello");会报错,要求使用strcpy_s,但参数类型又不符合条件?

问题
全部回复
-
Hi yepanerd,
感谢在MSDN论坛发帖。
>>strcpy(str, "hello");会报错,要求使用strcpy_s,但参数类型又不符合条件?
请提供一下str的定义,方便我们查找错误原因。
strcpy_s第二个参数为字符数。第三个参数才是源字符串。可参照上面回复中的第二个例子。
或者你也可以使用memcpy_s或者memcpy,直接在两个内存缓冲区中拷贝。
char source[] = "hello"; char dest[sizeof(source)]; memcpy_s(dest, sizeof(dest), source, sizeof(source));
希望对你有所帮助。
Best Regards,
Sera Yu
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
- 已建议为答案 Baron Bi 2016年9月26日 1:55