home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / GENCSRC.ZIP / UPLOW.C < prev    next >
C/C++ Source or Header  |  1987-11-21  |  1KB  |  43 lines

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