Professional Documents
Culture Documents
Ramesh Assignment II
Ramesh Assignment II
C-PROGRAMMING-II ASSIGNMENT-II
QUESTION :
Design a file copy authenticity checking system.Assume a test file file 1 with content.Now append the end of the file with a word that is formed by the first letter of the each word in the file.Now copy the file to a new file and repeat the procedure.Now verify the appended word in the file 1 and file 2.If the words are equal declare that the file copy is authentic ,else declare as copy infected.
AIM :
To design a file copy authenticity system using C program and check the authenticity of the file.
ALGORITHM :
* Start the program
* Declare file pointers fp1 and fp2 * Declare the function copy * Open the file fp1with * Then open/create fp2 * Then copy fp1 to fp2 using copy function * Compare the two files whether the appended file is correct or not
Stop the program} read permission
FLOWCHART:
start
Copy(fp1,fp2)
Copy (fp1,fp2)
PROGRAM CODING :
#include<stdio.h> #include<conio.h> #include<stdlib.h> Void copy(FILE *fp1,FILE *fp2) { char ch; while(!feof(fp)) { ch=fgetc(fp1); fputc(ch,fp2) } fclose(fp1); fclose(fp2); } main(int argc,char *argv[]) { FILE *fp1,*fp2; Void copy(FILE *,FILE *); fp1=fopen(argv[1],r); if(fp1==NULL) printf(FILE %s is not found\n,argv[1]); getch(); } fp2=fopen(argv[2],r); if(fp2==NULL) { fp2=open(argv[2],w); copy(fp1,fp2); printf(FILE is copied:\n); } else { printf(FILE %s exists,overwrite? If yes type y,else type n for no,argv[2]); fflush(stdin); if(ch=y// ch==y))
{ fclose(fp2); fp2=fopen(argv[2],w); copy(fp1,fp2); printf(FILE is copied:\n); } else printf(program is terminating without copying); strcmp(fp1,fp2); if(fp1==fp2) { printf(the file copy is authentic); } else printf(the file copy is infected); getch(); }
OUTPUT :
FILE is copied. FILE is copied. The file copy is authentic.
RESULT:
Hence a program to design a file copy authenticity system using C program and check the authenticity of the file has been written and the output was verified successfully.