Versions Compared

Key

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

...

Wiki Markup
C99 Section 5.1.2.2.3 has this to say about returning from {{main()}} \[[ISO/IEC 9899:-1999|AA. C References#ISO/IEC 9899-1999]\]:

...

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

int write_data(void) {
  char const *file namefilename = "hello.txt";
  FILE *f = fopen(file namefilename, "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(void) {
  char const *filefilename name = "hello.txt";
  FILE *f = fopen(file namefilename, "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;
}

...

Wiki Markup
\[[ISO/IEC 9899:-1999|AA. C References#ISO/IEC 9899-1999]\] Section 5.1.2.2.3, "Program termination," and Section 7.20.4, "Communication with the environment"
\[[ISO/IEC PDTR 24772|AA. C References#ISO/IEC PDTR 24772]\] "REU Termination strategy"

...