Home      Affiliated Colleges      Course content      First Sem     Second Sem     Third Sem     Fourth Sem     Fifth Sem     Sixth Sem     Seventh Sem     Eighth Sem     Lab report 4th sem     Contact    

Monday, August 9, 2010

Introduction to Cryprography: Write a program to create a copy of a text file in the same directory.


Program:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

void main()
{

    FILE *fs,*ft;
    char ch;
    clrscr();

    fs = fopen("vk.txt","r");
    if(fs==NULL)
    {
    printf("Cannot open source file ! Press key to exit.");
    getch();
    exit(0);
    }

    ft = fopen("ck.txt","w");
    if(ft==NULL)
    {
    printf("Cannot copy file ! Press key to exit.");
    fclose(fs);
    getch();
    exit(0);
    }

    while(1)
    {
    ch = getc(fs);
    if(ch==EOF)
    {
    break;
    }
    else
    putc(ch,ft);
    }

    printf("File copied succesfully!");
    fclose(fs);
    fclose(ft);
}

No comments:

Post a Comment

^ Scroll to Top Related Posts with Thumbnails ^ Go to Top