|
Well, on the above lines, i could further deduce:
1. in one case, k was pointing to stdout (dont know how!), coz its memory contents were that of my printf statement, prior to the sprintf. (Surprising!)
2. In one case, k was pointing to the string part of my sprintf statement. Hence again, it is not illegal, and the program would work. (Seems possible).
However, this kind of valid but garbage initializations seem to happen only when variable j is declared. Else, the program halts by SEGV.
But i still believe that this is a special and one-off case. Guess the same code would not work on another machine. (Mine is Solaris).
Any comments/inputs/further insight anyone?
|