PDA

View Full Version : read in and write out



02-21-2001, 04:30 PM
please tell me how to read in a .JPEG file, and rewrite it using a different filename? Please help...

rts
02-21-2001, 05:16 PM
Originally posted by happyhappy:
please tell me how to read in a .JPEG file, and rewrite it using a different filename? Please help...

Oh... how about something like:


FILE *in, *out;
char buff[1024];

in = fopen("mypic.jpg", "rb");

out = fopen("mypic2.jpg", "wb");

while (fread(buff, sizeof(buff), 1, in) > 0)
{
fwrite(buff, sizeof(buff), 1, out);
}

fclose(in);
fclose(out);


That's just off the top of my head, so, watch for bugs.

JoeMac
02-22-2001, 04:40 AM
If all you need is a copy, you could try
system("copy file.jpg newfile.jpg");