strcopy in c code example
Example 1: strcpy in C
#include <stdio.h>
#include <string.h>
int main() {
char str1[20] = "C programming";
char str2[20];
strcpy(str2, str1);
puts(str2);
return 0;
}
Example 2: strcpy
#include <stdio.h>
#include <string.h>
int main ()
{
char str1[]="Sample string";
char str2[40];
char str3[40];
strcpy (str2,str1);
strcpy (str3,"copy successful");
printf ("str1: %s\nstr2: %s\nstr3: %s\n",str1,str2,str3);
return 0;
}
Example 3: strcpy en c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char Temp[255];
strcpy(&Temp,"Gladir");
strcpy(&Temp,"ABC");
strcpy(&Temp,"Gladir.com");
puts(&Temp);
return 0;
}
Example 4: strcmp in c
#include <stdio.h>
#include <string.h>
int main()
{
char str1[] = "abcd", str2[] = "abCd", str3[] = "abcd";
int result;
result = strcmp(str1, str2);
printf("strcmp(str1, str2) = %d\n", result);
result = strcmp(str1, str3);
printf("strcmp(str1, str3) = %d\n", result);
return 0;
}