home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / GCC / GERLIB_USR08B.LHA / gerlib / examples / test / startup / gertest.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-12  |  2.0 KB  |  93 lines

  1. #include <fstream.h>
  2. #include <iostream.h>
  3. #include <stdio.h>
  4.  
  5. extern "C" {
  6.  
  7. #include <exec/types.h>
  8. #include <inline/exec.h>
  9. #include <clib/alib_protos.h>
  10.  
  11. int     atexit (void (*)(void));
  12.  
  13. struct Library *MathTransBase;
  14. struct Library *MathBase;
  15. struct Library *MathIeeeDoubBasBase;
  16. struct Library *MathIeeeDoubTransBase;
  17. struct Library *UtilityBase;
  18. };
  19.  
  20.  
  21. void close_math(void)
  22. {
  23.     struct Library *lib;
  24.     if(MathBase)                 { lib=(Library *)MathBase;                CloseLibrary(lib); }
  25.     if(MathTransBase)            { lib=(Library *)MathTransBase;         CloseLibrary(lib); }
  26.     if(MathIeeeDoubBasBase)     { lib=(Library *)MathIeeeDoubBasBase;    CloseLibrary(lib); }
  27.     if(MathIeeeDoubTransBase)    { lib=(Library *)MathIeeeDoubTransBase;    CloseLibrary(lib); }
  28.     if(UtilityBase)                { lib=(Library *)UtilityBase;            CloseLibrary(lib); }
  29. }
  30.  
  31. BOOL init_math(void)
  32. {
  33.     atexit(close_math);
  34.  
  35.     MathBase              = OpenLibrary((STRPTR)"mathffp.library",0L);
  36.     MathTransBase         = OpenLibrary((STRPTR)"mathtrans.library",0L);
  37.     MathIeeeDoubTransBase = OpenLibrary((STRPTR)"mathieeedoubtrans.library",0L);
  38.     MathIeeeDoubBasBase   = OpenLibrary((STRPTR)"mathieeedoubbas.library",0L);
  39.     UtilityBase           = OpenLibrary((STRPTR)"utility.library",0L);
  40.  
  41.     if(MathBase && MathTransBase && MathIeeeDoubTransBase && MathIeeeDoubBasBase && UtilityBase)
  42.         return TRUE;
  43.     else return FALSE;
  44. }
  45.  
  46. int main(void)
  47. {
  48.     if(init_math())
  49.     {
  50.         cout << "Hallo :" ;
  51.         printf("Dies ist ein Test !! Bitte String eingeben:");
  52.  
  53.         char hallo[100];
  54.  
  55.         cin >> hallo;
  56.  
  57.         cout << hallo << endl;
  58.         cout << hex << 100 << endl;
  59.  
  60.         cout << "Bitte float eingeben: ";
  61.         float f;
  62.         cin >> f;
  63.         if(cin)
  64.             cout << f << endl;
  65.         else
  66.             cout << "Ungültige Zahl !" << endl;
  67.  
  68.         cout << "Bitte double eingeben: ";
  69.         double d;
  70.         cin >>d;
  71.  
  72.         if(cin)
  73.         {
  74.             cout << d << endl;
  75.  
  76.             while(d)
  77.             {
  78.                 cout << d << endl;
  79.                 d/=10.0;
  80.             }
  81.         }
  82.         else
  83.             cout << "Ungültige Zahl !" << endl;
  84.  
  85.         return 0;
  86.     }
  87.     else
  88.     {
  89.         printf("Not able to open all math-libraries !\n");
  90.         return 20;
  91.     }
  92. }
  93.