I am using Ubuntu and gcc for compilation.
#include<stdio.h>
void main()
{
char *c =0 ;
while(1)
{
printf("%p",c);
c++;
// printf("%c",*c); // behavior after un-commenting this line is strange.
}
}
When I execute this code, it start printing large number of addresses which is perfectly fine. But when I un-comment printf("%c",*c) , The code don't even print first address and produce segmentation fault. I know what segmentation fault is and I intentionally wrote this code But I was expecting it would print few addresses (at-least the first address) before segmentation fault but it simply terminates without printing anything