๐Ÿ’ป
B.TECH I YEAR โ€ข I SEMESTER โ€ข R25

Programming for Problem Solving - Lab Manual

C Programming Laboratory โ€ข Program Solution

๐Ÿ“˜ R25 Regulation ๐ŸŽ“ I Year ๐Ÿ“š I Semester ๐Ÿ’ป C Programming ๐Ÿงช Lab Program
Selected Program

Write a C program which copies one file to another, replacing all lowercase characters with their uppercase equivalents.

โ† All Lab Programs

Write a C program which copies one file to another, replacing all lowercase characters with their uppercase equivalents.

file1.txt
Welcome to StudyGlance
C Program
//copies one file to another, replacing all lowercase characters with their uppercase equivalents.
#include <stdio.h>
#include <ctype.h>   

int main() {
    FILE *src, *dest;
    char ch;

    // Open source file
    src = fopen("file1.txt", "r");
    if (src == NULL) {
        printf("Error: Cannot open source file.\n");
        return 1;
    }

    // Open destination file
    dest = fopen("file2.txt", "w");
    if (dest == NULL) {
        printf("Error: Cannot create destination file.\n");
        fclose(src);
        return 1;
    }

    // Copy characters with conversion
    while ((ch = fgetc(src)) != EOF) {
        fputc(toupper(ch), dest);
    }

    printf("File copied successfully with uppercase conversion.\n");

    // Close files
    fclose(src);
    fclose(dest);

    return 0;
}

OUTPUT
File copied successfully with uppercase conversion.
file2.txt
WELCOME TO STUDYGLANCE

๐Ÿ’ป Run This C Program

Write a C program which copies one file to another, replacing all lowercase characters with their uppercase equivalents.
The selected C program is loaded automatically. Edit the code, provide input through STDIN and click Run.

The compiler is embedded using OneCompiler. Your program runs in the embedded C environment; Study Glance does not execute C code directly on your web server.
โ† Back to PPS Lab Programs ๐Ÿ“š All Lab Manuals