I tried the following code on Linux
#include<stdio.h>
int main()
{
char *p=NULL;
printf("%s",p);
return 0;
}
#include<stdio.h>
int main()
{
char *p=NULL;
printf("%s\n",p);
return 0;
}
The first one outputs: (null)
While the second one causes a segmentation fault.
Why does \n
make such a difference?