808 views

1 Answer

1 1 vote
O/P

1. puts(a);//passes base adress of array a to puts fn which try to print untill it find '\0' which never occur

So here o/p of this statement is :- abc then appended with some garbage character.

2. sizeof(&a[0]);

Explanation:- &a[0] gives base adress of String  constant "abc" and it considers the '\0' char @ end of the string constant by default ..So here o/p is 4

Note:- if Here we only Changes a[50]="abc" also the o/p of above sizeof statement is 4 only bcz it deal with the string constant size.

But if we are writing sizeof(a) then it return 50 for a[50] and 3 for given question.
Position:
Show:

Related questions

6 6 votes
3 answers 3 answers
1.2k
1.2k views
papesh asked Aug 15, 2016
1,198 views
int i; i=5; i=i++; printf("%d",i);What is output of this program??Is it undefined behavior ?? Why??
1 1 vote
2 2 answers
808
808 views
papesh asked Aug 11, 2016
808 views
Suppose in my c program having infinite loop and it is printing garbase values ... Because of some logical errors... So till what time it will run and why ??? Will it giv...