Problem in finding output of a program

Sukesh Shukla
Sukesh Shukla used Ask the Experts™
on
What will be the output of this program, please explain


#include<stdio.h>
#include<string.h>

int main()
{
    static char s[] = "Hello!";
    printf("%d\n", *(s+strlen(s)));
    return 0;
}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
This self-study or homework assignment is quite involved.
>> What will be the output of this program?
When you run the program what output did you get?

>> strlen(s)
What does this mean? What does this expression return? What is its data type?
(If you do not know, then modify your program to print out this value.
http://www.cplusplus.com/reference/cstring/strlen/?kw=strlen

>> s + strlen(s)
What does this mean? What does this expression return? What is the data type of s?
What is the data type of s + strlen(s) ?
(If you do not know what value is returned, then modify your program to print out this value.
https://www.cs.umd.edu/class/sum2003/cmsc311/Notes/BitOp/pointer.html

>> *(s+strlen(s))
What does the * operator mean in this expression?
http://boredzo.org/pointers/
http://www.cplusplus.com/doc/tutorial/pointers/

Author

Commented:
I've requested that this question be deleted for the following reason:

Doubt cleared
If my questions, tips, and suggestions, to guide the author, and associated learning links, helped the author to say "doubt cleared", then don't you think my post should be accepted. BTW, in the future, you are free to ask follow up questions if you have more specific issues. That may help speed up your learning process.

Author

Commented:
I've requested that this question be deleted for the following reason:

complete

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial