home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / turbopas / parstp25.zip / CALCCW.CPP < prev    next >
C/C++ Source or Header  |  1994-02-14  |  601b  |  33 lines

  1. // callcw.c - An example of a C program that uses the parser
  2.  
  3. #include <string.h>
  4. #include "parslib.h"
  5. #include <stdio.h>
  6. #include <math.h>
  7.  
  8. char s[100] = "";
  9. double result;
  10. short valid;
  11.  
  12. int main()
  13. {
  14.   printf("CALC CW - HyperAct Inc.\n");
  15.   // printf("%ld, %ld", &s, &valid);
  16.   while (strcmp(s, "EXIT") != 0) {
  17.    printf("CALC> ");
  18.     gets(s);
  19.     strupr(s);
  20.     if (strcmp(s, "EXIT") != 0) {
  21.         result = GETEXPR(s, valid);
  22.         if (valid)
  23.             printf("\n = %E\n", result);
  24.         else
  25.             printf("\n error at position %d\n", floor(result));
  26.     } // if ..
  27.   } // while .. 
  28.   return 0;
  29. }
  30.  
  31.  
  32.  
  33.