首页 > 代码库 > 关于strcpy_s
关于strcpy_s
#include"stdafx.h" #include<iostream> #include<cstring> int main() { using namespace std; char animal[20] = "bear"; const char* bird = "wren"; char* ps; cout << "Enter a kind of animal: "; cin >> animal; ps = animal; cout << "Before using strcpy_s(): " << endl; cout << animal << " at " << (int *)animal << endl; cout << ps << " at " << (int*)ps << endl; ps = new char[strlen(animal) + 1]; cout << "sizeof ps: " << sizeof ps << endl; strcpy_s(ps,strlen(animal)+1, animal); cout << "After using strcpy_s(): " << endl; cout << animal << " at " << (int *)animal << endl; cout << ps << " at " << (int*)ps << endl; delete [] ps; cin.get(); cin.get(); return 0; }
strlen 三个参数的情况下,第二个参数表示numberOfElements
关于strcpy_s
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。