vs上編譯不通過,慕課上卻可以,尋求原因
#include?<string.h> #include?<iostream> using?namespace?std; int?main(void) { //在堆中申請100個char類型的內(nèi)存 char?*str?=?new?char[100]; //拷貝Hello?C++字符串到分配的堆中的內(nèi)存中 strcpy(str,?"Hello?imooc"); //打印字符串 cout?<<?str?<<?endl; //釋放內(nèi)存 delete[]str; str?=?NULL; return?0; }
錯誤 1 error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
錯誤就是以上所描述,想不通那個代碼有什么問題
2017-03-31
代碼不用糾結(jié),沒有問題。是你VS的問題,建議新建項目,重新編譯。望采納!