home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / libcvers.zip / article_appendix / example / test.c < prev    next >
C/C++ Source or Header  |  2002-03-18  |  1KB  |  47 lines

  1. /* LIBC example/testcase program */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. /* Watcom has two modes, e.g. -3s vs. -3r. The former resembles _System and is
  7.    generally OK as long as the performance is not concerned. The latter is bit
  8.    like _Optlink but it's essential to us that -3r disagrees with _Optlink
  9.    about leading underscores. Therefore, when you compile with -3r, -4r or -5r,
  10.    be sure to include the following patch (add new variables upon demand): */
  11.  
  12. #ifdef WATCOM_FIX
  13.  #pragma aux stdin "*"
  14.  #pragma aux stdout "*"
  15.  #pragma aux stderr "*"
  16.  #pragma aux stdaux "*"
  17.  #pragma aux stdprn "*"
  18.  #pragma aux _timezone "*"
  19.  #pragma aux _daylight "*"
  20.  #pragma aux errno "*"
  21. #endif
  22.  
  23. /* Main routine */
  24.  
  25. int main(int argc, char **argv)
  26. {
  27.  float f=1.5;
  28.  int rc;
  29.  
  30.  /* Note: if you are writing an interactive application, or an application that
  31.     reports its progress to stdout, be sure to disable stdout/stderr buffering
  32.     with XPG.4 libs: */
  33.  setbuf(stdout, NULL);
  34.  setbuf(stderr, NULL);
  35.  if(argc<2)
  36.  {
  37.   printf("Usage: %s <n>\n"
  38.          "Where: <n> = errorlevel to finish with\n", argv[0]);
  39.   return(0);
  40.  }
  41.  rc=atoi(argv[1]);
  42.  printf("You requested errorlevel %u\n", rc);
  43.  f+=(float)rc;
  44.  printf("Now, for a simple floating-point test: %u + 1.5 = %3.1f\n", rc, f);
  45.  return(rc);
  46. }
  47.