I ran this code:
#include<stdio.h>
#include<string.h>
int main()
{
static char str1[] = "dills";
static char str2[20];
static char str3[] = "Daffo";
int i,j;
i = strcmp(strcat(str3, strcpy(str2, str1)), "Daffodills");
printf("%d", i);printf("\n");
printf("%s",str1);printf("\n");
printf("%s",str2);printf("\n");
printf("%s",str3);printf("\n");
printf("%s",strcpy(str2, str1));printf("\n");
printf("%s",strcat(str3, strcpy(str2, str1)));
return 0;
}
Output:
0
ills
dills
Daffodills
ills
Daffodillsills
- How str1 became "ills"?
- why strcpy is returning "ills"?
- Even if strcat(str3, strcpy(str2, str1)) returns Daffodillsills but the answer of strcmp is 0. Why?