bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

luc086.c (1466B)


      1 /*
      2  * Author  : Amit Dutta <amitdutta4255@gmail.com>
      3  * Date    : 08 Feb 2026
      4  * Repo    : https://github.com/notamitgamer/bsc
      5  * License : MIT License (See the LICENSE file for details)
      6  */
      7 
      8 /* Write a program to copy contents of one file to another. While doing so replace all lowercase characters to their equivalent uppercase characters.
      9 */
     10 /* Let Us C, Chap- 19 (File Input/Output), Qn No.: B(b) */
     11 
     12 /* This file is auto-generated by a bot. */
     13 /* This code is not compiled; it is for reference only. */
     14 
     15 
     16 #include <stdio.h>
     17 #include <stdlib.h>
     18 #include <string.h>
     19 #include <ctype.h>
     20 
     21 void create_source_file();
     22 
     23 int main()
     24 {
     25     FILE *fs, *ft;
     26     char ch;
     27 
     28     create_source_file(); // Helper to make code runnable
     29 
     30     fs = fopen("source.txt", "r");
     31     if (fs == NULL)
     32     {
     33         printf("Cannot open source file.\n");
     34         exit(1);
     35     }
     36 
     37     ft = fopen("target.txt", "w");
     38     if (ft == NULL)
     39     {
     40         printf("Cannot open target file.\n");
     41         fclose(fs);
     42         exit(2);
     43     }
     44 
     45     while ((ch = fgetc(fs)) != EOF)
     46     {
     47         ch = toupper(ch);
     48         fputc(ch, ft);
     49     }
     50 
     51     printf("File copied successfully with uppercase conversion.\n");
     52     printf("Check 'target.txt' for results.\n");
     53 
     54     fclose(fs);
     55     fclose(ft);
     56 
     57     return 0;
     58 }
     59 
     60 void create_source_file()
     61 {
     62     FILE *fp = fopen("source.txt", "w");
     63     if (fp)
     64     {
     65         fprintf(fp, "This is a sample text.\nIt contains Lowercase letters.\n");
     66         fclose(fp);
     67     }
     68 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror