Monday, 11 June 2018

Program to read an existing file using File Handling

File Handling is concept that is used to read or write a file in your hard disk using some lines of code.
Here we gonna do the same using C langugae

/*Pre Processor used throughout the program*/
#include<stdio.h>
#include<conio.h>

int main()
{
    FILE *fp;
    char ch;
    clrscr();
    fp=fopen("Employee.txt","r");
    while(1)
    {
        ch=fgetc(fp);
        if(ch==EOF)
        break;
        printf("%c",ch);
    }
    printf("\n");
    fclose(fp);
    getch();
    return 0;

}


No comments:

Post a Comment