DIGIT-ARC read-only archive · snapshot: July 23, 2026

whts doing inside the printf..

3 posts · originally from https://geek.digit.in/community/threads/whts-doing-inside-the-printf.168541/

Ashokkumar01cbe
Ashokkumar01cbe Original post #1
Jan 6, 2013 at 1:47 PM
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
C
cosx #2
Jan 8, 2013 at 3:32 PM
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.
harshilsharma63
Jan 8, 2013 at 5:33 PM
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