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
  • 45,262
  • 17
  • 54
  • 100
hochan
  • 180
  • 1
  • 9

0 Answers0