Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <string.h>
- int i = 0, chars = 0;
- main()
- {
- char ch, fileName[140];
- FILE*tempFile;
- FILE*inFile;
- printf("Files available to be opened: \n");
- printf("\nfirstoption.txt");
- printf("\nsecondoption.txt");
- printf("\n\nPlease type the name of the file, with extension, you'd like to open: ");
- gets(fileName);
- inFile = fopen(fileName, "r+");
- tempFile = fopen(fileName,"r+");
- inFile = fopen(fileName, "r+");
- if (inFile == NULL)
- {
- printf("\nThe file could not be opened, please check that the file exists.");
- }
- else
- printf("The file was successfully opened!\n\n");
- while((ch=fgetc(inFile)) != EOF) {
- chars = chars + 1;
- fputc(toupper(ch), tempFile);
- }
- fclose(inFile); fclose(tempFile);
- printf("The characters in the file you chose have been changed.\nAll characters should be uppercase.\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement