Advertisement
Guest User

Ammended File->uppercase

a guest
Mar 31st, 2014
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.90 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5.  
  6. int i = 0, chars = 0;
  7.  
  8. main()
  9. {
  10.     char ch, fileName[140];
  11.     FILE*tempFile;
  12.     FILE*inFile;
  13.        
  14.     printf("Files available to be opened: \n");
  15.     printf("\nfirstoption.txt");
  16.     printf("\nsecondoption.txt");
  17.     printf("\n\nPlease type the name of the file, with extension, you'd like to open: ");
  18.     gets(fileName);
  19.    
  20.     inFile = fopen(fileName, "r+");
  21.     tempFile = fopen(fileName,"r+");
  22.    
  23.     inFile = fopen(fileName, "r+");
  24.     if (inFile == NULL)
  25.     {
  26.         printf("\nThe file could not be opened, please check that the file exists.");
  27.     }
  28.     else
  29.     printf("The file was successfully opened!\n\n");
  30.    
  31.     while((ch=fgetc(inFile)) != EOF) {
  32.         chars = chars + 1;
  33.         fputc(toupper(ch), tempFile);
  34.     }
  35.    
  36.     fclose(inFile); fclose(tempFile);
  37.     printf("The characters in the file you chose have been changed.\nAll characters should be uppercase.\n");
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement