Jump to content
ChetanaSforum

Recommended Posts


the output will be HELL when i tied in BC++ i got HELL followed by some junk value, i don't know the reason why.but when the variable is changed as a[5], output is exactly HELL.it works because, the printf is overloaded function and when printing a string (%s),it expects a pointer to be passed, in our case we are only passing a, which is an arraythus a refers to the first location of the array.

Share this post


Link to post
Share on other sites

I have tried I got output as HELL

hi i think :rolleyes: "HELL" strings is stored in memory as "HELL\0" but u cant c '\0' it is automatic in nature so if u ristrict is to a[4] it ll so garb value

Share this post


Link to post
Share on other sites

whenever we have to store any string value, it always takes one space more then total number of character, so that it can append NULL character, which means ENDing of that string. In this case total number of character is 4 (HELL), so it will take 5 block of memory to store the fifth NULL character. But here you are giving only 4 space so result comes with garbage value.hope this will help you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×