Reading Writing a character from a file || File handling || C programming
In this, we are going to see a program to write and read a character from a file with the help of C Programming Language.

 


#include <stdio.h>

void main()
{
    FILE *fptr;
    char ch;

    printf(" Enter any character: ");
    scanf("%c", &ch);

    fptr = fopen("sample.txt", "w");
    putc(ch, fptr);
    fclose(fptr);

    fptr = fopen("sample.txt", "r");
    ch = getc(fptr);

    printf(" Character: %c", ch);
}

//.....coded by ANANYA MAURYA

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post