Code Competitions

Coding competition

Monday, 13 May 2013

Program to write and read the contents in the file.

#include<stdio.h>
#include<conio.h>
void main()
{
    char i,c;
    FILE *p;
    clrscr();
    p=fopen("test.txt","w");
    while((c=getchar())!=EOF)
    {
        putc(c,p);
    }
    fclose(p);
    p=fopen("test.txt","r");
    while((c=getc(p))!=EOF)
    {
        printf("%c",c);
    }
    fclose(p);
    getch();
}

No comments:

Post a Comment