/* File calcisqr.h **********/ /* Projekt CalcIntSqr Quadrat einer ganzen Zahl (Bibliothek). Version 1.0 / 2002.04.01 Autor: pstrainer@gmx.net Files: calcisqr.h (this file), calcisqr.cpp, testmain.cpp */ #ifndef _my_library #define _my_library #include #include extern int isqr(int); #endif /* ========== eof ========== */ /* File testmain.cpp **********/ /* Projekt CalcIntSqr Quadrat einer ganzen Zahl (Bibliothek). Version 1.0 / 2002.04.01 Autor: pstrainer@gmx.net Files: calcisqr.h, calcisqr.cpp, testmain.cpp (this file) */ #include "calcisqr.h" #define myversion 2 // valid options: {1,2} // *************** Version 1 ******************** #if myversion==1 void main (void) { int i,q; printf("Projekt IntSqr\n"); i=123; q=isqr(i); printf("IntSqr(%d)=%d\n",i,q); } // *************** Version 2 ******************** #elif myversion==2 void main (void) { int i,q; printf("Projekt IntSqr\n\nAbbruch mit i=0\n"); i=1; while ( i!=0 ) { printf("\nEingabe einer ganzen Zahl: "); scanf("%d",&i); q=isqr(i); printf("IntSqr(%d)=%d\n",i,q); } #ifdef _DEBUG printf("\nPress any key to continue "); _getch(); #endif } // *************** Version ? ******************** #else void main (void) { printf("Makro #myversion wurde illegal definiert\n"); } #endif /* ========== eof ========== */ /* File calcisqr.cpp **********/ /* Projekt CalcIntSqr Quadrat einer ganzen Zahl (Bibliothek). Version 1.0 / 2002.04.01 Autor: pstrainer@gmx.net Files: calcisqr.h, calcisqr.cpp (this file), testmain.cpp */ #include "calcisqr.h" int isqr(int i) { /* Funktion isqr Quadrat einer ganzen Zahl Version 1.0 / 2002.04.01 Autor: pstrainer@gmx.net Syntax: #include "intsum.h" int i,q; ... q=isqr(i); Length: 3 lines of code */ return i*i; } /* ========== eof ========== */