CBFalconer wrote:
> somenath wrote:
>> I have some doubts fro the following program.
>>
>> #include<stdio.h>
>>
>> int main(void)
>> {
>> char **p = 0;
>> printf("%d\n", ++p);
>> return 0;
>> }
>>
>> The Output of the program is
>> 4
>> Could any body let me know how it prints 4?
>
> It can print anything it desires, or explode. All these are
> satisfactory examples of the undefined behaviour it exhibits. A
> pointer is not a signed integer.
>
But since this program displays undefined behavior, it
has some probability, *no* matter how infinitesimal that
probability may be, of doing exactly what the programmer
wants.
This is the only chance that programmers have... who know
so little about C. (Slim and none, and Slim just left town.)
--
+----------------------------------------------------------------+
| Charles and Francis Richmond richmond at plano dot net |
+----------------------------------------------------------------+