#include "stdafx.h" #include <iostream>
#include <string.h>
int _tmain(int argc, _TCHAR* argv[])
{
using namespace std;
char animal[20]="bear";
const char *bird="wren";
char *ps;
cout<<animal<<" and ";
cout<<bird<<endl;
cout<<"Eenter a kind of animal";
cin>>animal;
ps=animal;
cout<<ps<<" s!\n";
cout<<"Before using strcpy():\n";
cout<<animal<<" at "<<(int *)animal<<endl;
cout<<ps<<" at "<<(int *)ps<<endl; ps =new char[strlen(animal)+1];
strcpy(ps,animal);
cout<<"After using strcpy();\n";
cout<<animal<<" at "<<(int *)animal<<endl;
cout<<ps<<" at "<<(int *)ps<<endl;
delete[]ps;
return 0;
}
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.
#include <string.h>
int _tmain(int argc, _TCHAR* argv[])
{
using namespace std;
char animal[20]="bear";
const char *bird="wren";
char *ps;
cout<<animal<<" and ";
cout<<bird<<endl;
cout<<"Eenter a kind of animal";
cin>>animal;
ps=animal;
cout<<ps<<" s!\n";
cout<<"Before using strcpy():\n";
cout<<animal<<" at "<<(int *)animal<<endl;
cout<<ps<<" at "<<(int *)ps<<endl; ps =new char[strlen(animal)+1];
strcpy(ps,animal);
cout<<"After using strcpy();\n";
cout<<animal<<" at "<<(int *)animal<<endl;
cout<<ps<<" at "<<(int *)ps<<endl;
delete[]ps;
return 0;
}
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.