home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug064.arc / UPLOW.C < prev    next >
Text File  |  1979-12-31  |  1KB  |  42 lines

  1. #include "STDIO.H"
  2. #include "ctype.h"  /* Note - your compiler may not need this */
  3.  
  4. main()
  5. {
  6. FILE *fp;
  7. char line[80], filename[24];
  8. char *c;
  9.  
  10.    printf("Enter filename -> ");
  11.    scanf("%s",filename);
  12.    fp = fopen(filename,"r");
  13.  
  14.    do {
  15.       c = fgets(line,80,fp);   /* get a line of text */
  16.       if (c != NULL) {
  17.          mix_up_the_chars(line);
  18.       }
  19.    } while (c != NULL);
  20.  
  21.    fclose(fp);
  22. }
  23.  
  24. mix_up_the_line(line)   /* this function turns all upper case
  25.                            characters into lower case, and all
  26.                            lower case to upper case. It ignores
  27.                            all other characters.               */ 
  28. char line[];
  29. {
  30. int index;
  31.  
  32.    for (index = 0;line[index] != 0;index++) {
  33.       if (isupper(line[index]))     /* 1 if upper case */
  34.          line[index] = tolower(line[index]);
  35.       else {
  36.          if (islower(line[index]))  /* 1 if lower case */
  37.             line[index] = toupper(line[index]);
  38.       }
  39.    }
  40.    printf("%s",line);
  41. }
  42.