C Programming - Strings - Discussion

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

int main()
{
    static char s[] = "Hello!";
    printf("%d\n", *(s+strlen(s)));
    return 0;
}
8
0
16
Error
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
38 comments Page 3 of 4.

Prasad said:   1 decade ago
Thanks Dipankar your answer is so clear, I understood.

Anant said:   10 years ago
It will print 0 because it points to null character.

Gnanavel said:   1 decade ago
Very short example and I understood. Thanks.

Snehal said:   9 years ago
Thank you @Dipankar. Nice explanation.

Omkar said:   1 decade ago
Thanks Dipankar for Good explanation

Mala said:   7 years ago
Thanks to all for explaining this.
(1)

Kalyan said:   6 years ago
The answer is 6 in GCC compiler.
(2)

Kannan said:   1 decade ago
@Dipankar explained well.

Lak said:   1 decade ago
Length of string = 8;

Ragini said:   8 years ago
Thank you @Kalyani.


Post your comments here:

Your comments will be displayed after verification.