1

I have a question that the segmentation fault was caused by just adding a new line to print. I use clang instead of gcc, Ubuntu 18.

What principles are hiding?

#include <stdio.h>

int     main(void)
{
    char            *newLineLocation = NULL;

    printf("%s \n", newLineLocation);
    printf("%s\n", newLineLocation);
    return (0);
}

Output:

holee@DESKTOP-GCFUM3M:~/hochan$ ./a.out 
(null) 
Segmentation fault (core dumped)
Jabberwocky
  • 48,281
  • 17
  • 65
  • 115
hochan
  • 220
  • 3
  • 10

0 Answers0