//How to copy String in C++? 'Strncpy' in C++.
#include <iostream>
using namespace std;
int main()
{
const int size = 15;
char string[size] = "He. is.";
char a[size];
strcpy (a,string);
cout << a;
}
//===========================================================================
Write A function to copy one String into Another.
#include <iostream>
using namespace std;
void stringcopy(char s[], int size);
int main()
{
const int size = 15;
char string[size] = "He. is.";
stringcopy(string, size);
cout << string << endl;
return 0;
}
void stringcopy(char s[], int size)
{
char *a = new char [size];
strcpy (a,s);
cout << a << endl;
}
No comments:
Post a Comment