whts doing inside the printf..

Ashokkumar01cbe

Broken In
when i compile the below code
1) program

main( )
{
printf ( 5 + "Good Morning " ) ;
}
i got the result as Morning.. and in another code
2) program

main( )
{
printf ( "%c", "abcdefgh"[4] ) ;
}
in the 2nd program i got the result a "e"..
please explain me whats going inside the printf
 

cosx

Broken In
when i compile the below code
1) program

main( )
{
printf ( 5 + "Good Morning " ) ;
}
i got the result as Morning.. and in another code
2) program

main( )
{
printf ( "%c", "abcdefgh"[4] ) ;
}
in the 2nd program i got the result a "e"..
please explain me whats going inside the printf

1. in first case it seems that printf is skipping fisrt 5 charcters ( 5+ is controlling this)
2. in second case fifth cahracter as pointed by the index [4] is getting perinted.
 
1) program

main( )
{
printf ( 5 + "Good Morning " ) ;
}
i got the result as Morning..

*stackoverflow.com/questions/3332611/how-is-printf-statement-interpreted

2) program

main( )
{
printf ( "%c", "abcdefgh"[4] ) ;
}
in the 2nd program i got the result a "e"..

*stackoverflow.com/questions/11907030/what-does-this-printf-mean
 
Top Bottom