1/* strcpy example */
2#include <stdio.h>
3#include <string.h>
4
5int main ()
6{
7 char str1[]="Sample string";
8 char str2[40];
9 char str3[40];
10 strcpy (str2,str1);//str1 copies to str2
11 strcpy (str3,"copy successful");
12 printf ("str1: %s\nstr2: %s\nstr3: %s\n",str1,str2,str3);
13 return 0;
14}
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4
5int main()
6{
7 char Temp[255];
8 strcpy(&Temp,"Gladir");
9 strcpy(&Temp,"ABC");
10 strcpy(&Temp,"Gladir.com");
11 puts(&Temp);
12 return 0;
13}
1#include <stdio.h>
2#include <string.h>
3
4int main() {
5 char str1[20] = "C programming";
6 char str2[20];
7
8 // copying str1 to str2
9 strcpy(str2, str1);
10
11 puts(str2); // C programming
12
13 return 0;
14}