Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Let's write a program, /prog/...

Name: Anonymous 2008-04-01 13:07

Forget about header files. Just write.


int main(int argc, char *argv[]) {

Name: Anonymous 2008-04-04 8:24

>>54
The only meaningful and portable values to return from main (or exit or _Exit) are EXIT_SUCCESS, 0 and EXIT_FAILURE.
The first two both indicate success while the last indicates failure.
Learn to C99.

My version of link.c? Fine


#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv) {

    if(argc != 2) {
        fputs("link: missing operand\n");
        return EXIT_FAILURE;
    }

    if(link(argv[1], argv[2]) == -1) {
        perror("link");
        abort();
    }

    return 0;
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List