Copy character pointer type string to character array
//copy character pointer to character array
#include<iostream.h>
using namespace std;
int main(int argc, char *argv[])
{
void copy(char*, char*);
char* st="Hello world";
char st1[100];
copy(st1,st);
cout<<st1;
return 0;
}
void copy(char* s1, char* s2)
{
while(*s2)
*s1++=*s2++;
*s1='\0';
}
Comments
Post a Comment