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

Loading Question

asked in Programming by Loyal (3.8k points)   | 119 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.6k points)  

Related questions

+1 vote
1 answer
1
asked in Programming by KISHALAY DAS Boss (6.4k points)   | 72 views
0 votes
0 answers
3
Top Users Jan 2017
  1. Debashish Deka

    7172 Points

  2. Habibkhan

    4696 Points

  3. Vijay Thakur

    4308 Points

  4. sudsho

    4090 Points

  5. saurabh rai

    4024 Points

  6. Arjun

    3292 Points

  7. santhoshdevulapally

    3066 Points

  8. GateSet

    3016 Points

  9. Bikram

    3014 Points

  10. Sushant Gokhale

    2892 Points

Monthly Topper: Rs. 500 gift card

18,838 questions
23,808 answers
51,589 comments
20,148 users