home *** CD-ROM | disk | FTP | other *** search
-
- /*
- Compiler: Turbo C 2.0 Small Memory Model;
- Requires: chartab.obj;
- Warning: Compile with default char type = unsigned
- and alignment = word;
- */
-
- #include <stdio.h>
- #include <string.h>
-
- extern char up_case[256], low_case[256];
- extern char *str2upper(char *dest, char *source);
- extern char *str2lower(char *dest, char *source);
-
- #define up_string(dest,source) {\
- unsigned zz,z=0;\
- do{\
- zz=source[z];\
- dest[z++]=up_case[zz];\
- }while(zz);\
- }
-
- #define low_string(dest,source) {\
- unsigned zz,z=0;\
- do{\
- zz=source[z];\
- dest[z++]=low_case[zz];\
- }while(zz);\
- }
-
-
- char outstring[BUFSIZ], instring[BUFSIZ] = "iS ThIs MiXeD CaSe?";
-
- void main(void)
- {
- int i, j, k = 0;
-
- printf("\n");
-
- /*
- * print alpha portions of tables and check
- * non-alpha portions in tables for errors
- */
- for(i = 0;i < 16;i++) {
- printf("\n");
-
- for(j = 0;j < 15;j++) {
- if((k >= 'A' && k <= 'Z') || (k >= 'a' && k <= 'z'))
- printf("%c %c ", up_case[k], low_case[k]);
- else if(k != up_case[k] || k != low_case[k])
- printf("\n\n\tError in a char tabel at pos %d\n\n", k);
-
- ++k;
- }
- }
-
- /*
- * try conversion functions
- */
- printf("\n");
- printf("%s\n", strcpy(outstring, instring));
- printf("%s\n", str2lower(outstring, instring));
- printf("%s\n", str2upper(outstring, instring));
- printf("%s\n", strcpy(outstring, instring));
- printf("%s\n", str2lower(outstring, outstring)); /* try in-place conv */
-
- /*
- * try conversion Macros
- */
- up_string(outstring,instring);
- printf("%s\n", outstring);
- low_string(outstring,instring);
- printf("%s\n", outstring);
- }
-