DEV Community

Yaroslav Polyakov
Yaroslav Polyakov

Posted on • Updated on

Every C program has main()? (False)

actually, _start is real magic word.

nomain.c:

#include <stdio.h>

extern void _exit(register int);

int _start(){
    printf("Hello world!\n");
    _exit(0);
}
Enter fullscreen mode Exit fullscreen mode
$ gcc -o nomain nomain.c -nostartfiles
$ ./nomain 
Hello world!
Enter fullscreen mode Exit fullscreen mode

Top comments (0)