Code Competitions

Coding competition
Showing posts with label update and display using seek. Show all posts
Showing posts with label update and display using seek. Show all posts

Monday, 27 May 2013

program to update the contents of file

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
void main()
{
    FILE *fp;
    clrscr();
    fp=fopen("ab","w+");
    char ch;
    while((ch=getchar())!=EOF)
    {
        putc(ch,fp);
    }
    cout<<"the entered list is \n";
    fflush(fp);
    fseek(fp,0L,0);
    while((ch=getc(fp))!=EOF)
    {
        cout<<ch;
    }
    fclose(fp);
    getch();
}

OUTPUT: