what will be the value of x for the following code snippet?
char str1[]="dills";
char str2[20]="hello";
char str3[]="daffo";
int x;
x=strcmp("daffofills",strcat(str3,strcpy(str1,str2)));
Answers
Answered by
0
The output of the following will be -4. The reason for this is because there is function named strcmp(), which simply compares the respective characters of two words, and when there is a mismatch found in the words, then the difference between the ASCII code of the character is returned by the function.
Here in the program, the difference between the ASCII code of the first mismatched character is 4 so the output is -4.
Similar questions