Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edited by sciSpider (sch jbop) (X_X)@==(Q_Q)@

...

Code Block
void _start() {
  /* ... */
  exit(main(argc, argv));
}

Wiki Markup
However, making it out of main is conditional on correctly handling all errors in a way that does not force premature termination (see \[[ERR00-A. Adopt and implement a consistent and comprehensive error handling policy]\] and \[[ERR05-A. Application-independent code must provide error detection without dictating error handling]\]).

...

Code Block
bgColor#FFCCCC
#include <stdlib.h>
#include <stdio.h>

int write_data() {
  char const char* filename = "hello.txt";
  FILE *f = fopen(filename, "w");
  if (f == NULL) {
    /* handle error */
  }
  fprintf(f, "Hello, World\n");
  /* ... */
  abort(); /* oops! data might not get written! */
  /* ... */
  return 0;
}

int main(void) {
  write_data();
  return 0;
}

...

Code Block
bgColor#ccccff
#include <stdlib.h>
#include <stdio.h>

int write_data() {
  char const char* filename = "hello.txt";
  FILE *f = fopen(filename, "w");
  if (f == NULL) {
    /* handle error */
  }
  fprintf(f, "Hello, World\n");
  /* ... */
  exit(EXIT_FAILURE); /* writes data & closes f. */
  /* ... */
  return 0;
}

int main(void) {
  write_data();
  return 0;
}

...