Replace First Letter with Capital Letter
Write a C Program to Replace First Letter with Capital Letter. Here’s simple Program to Replace First Letter with Capital Letter in C Programming Language.
Below is the source code for C Program to Replace First Letter with Capital Letter which is successfully compiled and run on Windows System to produce desired output as shown below :
SOURCE CODE : :
/* C Program to Replace First Letter with Capital Letter */ #include <stdio.h> #include <stdlib.h> int main() { FILE *fp1; int return_val; char * arrr = "C:\\Users\\acer\\Documents\\file4.txt"; if ((fp1 = fopen(arrr,"r")) == NULL) { printf("file cant be opened"); exit(0); } return_val = init_cap_file(fp1); if (return_val == 1) { printf("\nsuccess"); } else { printf("\n failure"); } return 0; } int init_cap_file(FILE *fp1) { char ch; ch = fgetc(fp1); if (ch >= 97 && ch <= 122) { fseek(fp1, -1L, 1); fputc(ch - 32, fp1); } while (ch != EOF) { if (ch == ' '|| ch == '\n') { ch = fgetc(fp1); if (ch >= 97 && ch <= 122) { fseek(fp1, -1L, 1); fputc(ch - 32, fp1); } } else ch = fgetc(fp1); } return 1; }
OUTPUT : :
success
Above is the source code for C Program to Replace First Letter with Capital Letter which is successfully compiled and run on Windows System.The Output of the program is shown above .
If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.
Thanks for reading the post….