The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+4 votes
163 views

Loading Question

asked in Programming by Veteran (12.3k points) | 163 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 (9.8k points)


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

28,947 questions
36,793 answers
91,077 comments
34,690 users