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

Loading Question

asked in Programming by Veteran (10.2k points)   | 128 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)   | 119 views
0 votes
0 answers
3


Top Users Mar 2017
  1. rude

    5236 Points

  2. sh!va

    3054 Points

  3. Rahul Jain25

    2920 Points

  4. Kapil

    2732 Points

  5. Debashish Deka

    2602 Points

  6. 2018

    1574 Points

  7. Vignesh Sekar

    1430 Points

  8. Bikram

    1424 Points

  9. Akriti sood

    1420 Points

  10. Sanjay Sharma

    1128 Points

Monthly Topper: Rs. 500 gift card

21,549 questions
26,889 answers
61,249 comments
23,251 users