Ashwin,
 
I see few problems in this code..
 
if ((output_file = fopen("output.jpg", "ab"))
1. Why are you opening the ouput file in append mode? If you run ur program more than once, the ouput file will no longer with exact replica of the original one. U wud just be appending the orig file data to the o/p file.
 
 
while((fgetc(input_file))!= EOF)
2. Why aren't u assigning ur variable "c" with the value of fgetc?? The value of fgetc is going nowhere.. You are just putting in some junk in o/p file..
    Use:
    while( (c = fgetc(input_file)) != EOF)
 
3. You forgot to close input file handle..
 
Cheers,
Amol
-----Original Message-----
From: ashwin mittal [mailto:[EMAIL PROTECTED]
Sent: 25 October 2004 17:29
To: C,C++ programming
Subject: (PT) Image File


Hi everybody,

I want to copy one picture (i.e. in gif format) to
other gif format file through C.

I dont want the copy command in C....

But the thing I want is through the file handling in C
and reading the contents and then copying the contents
to other file..
But that other file doesnt have any picture but the
size of that copied file is absolutely perfect..

Check this code and please tell me where I am wrong...

#include<stdio.h>
#include<conio.h>
void main()
{
        int c;
        FILE *output_file;
        FILE *input_file;
        if ((input_file = fopen("sample.jpg","rb")) ==
NULL)
        {
                fprintf(stderr, "Cannot read
properly\n");
        }
        if ((output_file = fopen("output.jpg", "ab"))
== NULL)
           fprintf(stderr, "Cannot write properly\n");
        else
        {
                while((fgetc(input_file))!= EOF)
                {
                        fputc(c,output_file);
                }
        fclose(output_file);
        }

getch();
}


           
__________________________________
Do you Yahoo!?
Y! Messenger - Communicate in real time. Download now.
http://messenger.yahoo.com





To unsubscribe : [EMAIL PROTECTED]




Yahoo! Groups Sponsor
ADVERTISEMENT
click here
Web Bug from http://portal.mxlogic.com/images/transparent.gif


Yahoo! Groups Links



To unsubscribe : [EMAIL PROTECTED]




Yahoo! Groups Sponsor
ADVERTISEMENT
click here
Web Bug from http://us.adserver.yahoo.com/l?M=315388.5526708.6599542.3001176/D=groups/S=:HM/A=2372354/rand=304380425


Yahoo! Groups Links

==============================================================================
This message is for the sole use of the intended recipient. If you received this message in error please delete it and notify us. If this message was misdirected, CSFB does not waive any confidentiality or privilege. CSFB retains and monitors electronic communications sent through its network. Instructions transmitted over this system are not binding on CSFB until they are confirmed by us. Message transmission is not guaranteed to be secure.
==============================================================================

Reply via email to