GATE CSE
First time here? Checkout the FAQ!
x
+4 votes
124 views

Loading Question

asked in Programming by Boss (7.3k points)   | 124 views
Please explain at the end what will be stored in str[10]. will it have d and if will be there then at which location.

@Rahul String Angel is stored like A,n,g,e,l,\0 . str[5] = '\0';

str[10] = 'd'; // some address (str+10) is assigned value 'd'.

Printf() in the next line prints the string from memory location str till it encounters null character. i.e., Angel

Angel
Thanks excellent explaination.
@mcjoshi If your thinking seems correct to you then add it as answer ,not as comment.

1 Answer

+3 votes

Credits to @mcjoshi

Answer is option (C) : Angel

String Angel is stored like A,n,g,e,l,\0 . str[5] = '\0';

str[10] = 'd'; // some address (str+10) is assigned value 'd'.

Printf() in the next line prints the string from memory location str till it encounters null character. i.e., Angel

answered by Boss (8.7k points)  

Related questions

+1 vote
1 answer
1
asked in Programming by KISHALAY DAS Boss (6.5k points)   | 109 views
0 votes
0 answers
3
Top Users Feb 2017
  1. Arjun

    5386 Points

  2. Bikram

    4230 Points

  3. Habibkhan

    3952 Points

  4. Aboveallplayer

    3086 Points

  5. Debashish Deka

    2564 Points

  6. sriv_shubham

    2318 Points

  7. Smriti012

    2240 Points

  8. Arnabi

    2008 Points

  9. mcjoshi

    1696 Points

  10. sh!va

    1684 Points

Monthly Topper: Rs. 500 gift card

20,863 questions
26,022 answers
59,696 comments
22,133 users