C Programming - Strings - Discussion

Discussion Forum : Strings - Find Output of Program (Q.No. 11)
11.
What will be the output of the program ?
#include<stdio.h>
#include<string.h>

int main()
{
    static char str1[] = "dills";
    static char str2[20];
    static char str3[] = "Daffo";
    int i;
    i = strcmp(strcat(str3, strcpy(str2, str1)), "Daffodills");
    printf("%d\n", i);
    return 0;
}
0
1
2
4
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
31 comments Page 3 of 4.

Musthak rahaman said:   6 years ago
The actual output for this is the process finished with exit code -6.

Naresh said:   1 decade ago
All strings declare in static it cannot modifie. So zero is answer.

Harsh said:   1 decade ago
As strings are immutable how is the strings modified.

Uday said:   6 years ago
strcmp() will always return the value 0.
(1)

Ani said:   1 decade ago
Whats the use of static char?

Sajal said:   1 decade ago
Explain the reason please.

Satwika said:   9 years ago
Nice explanation @Gautam.

Rajesh said:   1 decade ago
I agree with goutham.

Priya said:   5 years ago
Thanks @Goutham.

Rushikesh Bhosale said:   6 years ago
Thanks @Gautam.


Post your comments here:

Your comments will be displayed after verification.