Friday, December 28, 2012

PROGRAMS TO COPY IMAGE FILE

READ IMAGE FILE & COPY TO ANOTHER FILE:-



#include<iostream> 
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>

using namespace std;

int getimagedata(FILE*, FILE*);

void main()
{
FILE *f1,*f2;
f1=fopen("C:\\Users\\shubham\\Pictures\\photo.bmp","rb");
f2=fopen("C:\\Users\\shubham\\Pictures\\photo1.bmp","wb");

if(f1==NULL)
{
cout<<"file is empty";
}
else
{

while(!feof(f1))
{
char c=getimagedata(f1, f2);
cout<<c;
}
fclose(f1);
fclose(f2);

}

getch();
}

int getimagedata(FILE* f1,FILE* f2)
{
char ch;
ch=(char) getc(f1);
putc((char) ch,f2);
return(ch);
}

No comments:

Post a Comment