Interview Question
Developer Program EngineersCountry: India
Interesting question!
Passing NULL pointer to printf("%s",s) causes undefined behavior. So it may up to the compiler decision...
prinf() without "\n" (newline) puts data into buffer and waits for all data to be printed, while with "\n", it prints immediately (?).
But I really don't know why and why not segmentation fault occurs. Any expert here?
a[3] is a garbage valued (because it is coming off stack) pointer to a char
when it's passed to printf, printf will try to access characters a[3][0] then a[3][1] ... etc. until some a[3][k] is the '\0' character (signalling end of string).
if you are lucky and say a[3][0] just happens to be '\0', then there is a[4] garbage pointer to deal with on next iteration of the loop
What is the question?
Which company uses "void main" ?
think what happens printf tries to print a[3]
For illustrative purposes only:
- S O U N D W A V E March 10, 2014