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

Loading Question

asked in Programming by Veteran (10.6k points)   | 144 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.9k points)  


Top Users Jul 2017
  1. Bikram

    3782 Points

  2. manu00x

    2464 Points

  3. Debashish Deka

    1832 Points

  4. joshi_nitish

    1494 Points

  5. Arnab Bhadra

    1096 Points

  6. Arjun

    1054 Points

  7. Hemant Parihar

    1050 Points

  8. Shubhanshu

    972 Points

  9. Ahwan

    876 Points

  10. akash.dinkar12

    642 Points


23,953 questions
30,895 answers
70,108 comments
29,273 users