|
String copy
This example shows using strcpy library function.
12 | printf ( "First string : %s" , first); |
13 | printf ( "\nSecond string : %s" , second); |
17 | first = ( char *) malloc ( strlen (second) + 1); |
18 | strcpy (first, second); |
21 | second = ( char *) malloc ( strlen (temp) + 1); |
24 | printf ( "\n\nFirst string : %s" , first); |
25 | printf ( "\nSecond string : %s" , second); |
|
It gives the following output,
First string : ONE
Second string : TWO
First string : TWO
Second string : ONE
|
|