2/22/2009

C Program To Read And Write The Information Of An Employee Using Files


/* C Program To Read And Write The Information Of An Employee Using Files */
#include<stdio.h>
#include<conio.h>

void main()
{
    char ch;
    FILE *fp=fopen("C:\\Input.txt","r");
    if(fp==NULL)
    {
        printf("Can not find the file!");
        exit(0);
    }
    while(1)
    {
        ch=fgetc(fp);
        if(ch==EOF) break;
        printf("%c",ch);
    }
    fclose(fp);
 }
Out Put:

Employee ID     Name            Salary          Department
-----------------------------------------------------------
100             Mohammad        7000($)         Management
200             Kamran          6500($)         Accounting
300             Keyvan          4000($)         Sales

No comments:

Post a Comment