Thanks again ahead of time.
I am looking to write a program that opens a text file, takes the text and converts all characters (excluding special and numbers) to capital letters.
I am unsure where I am going wrong for some reason I am using d, and cannot get it to code correctly keep getting char to char error. Please let me know what I have messed up as I am a little confused.
Code:#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #define MAXCHAR 250 int main(void) { FILE *fp; char filename[MAXCHAR]; char d; printf("Enter the name of the file to open\n"); fgets(filename, MAXCHAR, stdin); filename[strlen(filename) - 1] = '\0'; if (!(fp = fopen(filename, "r+"))) { printf("Unable to open %s\n", filename); exit(EXIT_FAILURE); } else { fgets(d,MAXCHAR,fp); if (fp > 'a' && fp < 'z') { fp = tolower(fp); } fputs(fp); } system("Pause"); return 0; }



LinkBack URL
About LinkBacks



