
help on putting different image type
Quote:
>I have been writing a program to display a gif on the computer screen.
However
>when I compile it, the picture does not show up. Here's the source code:
>void Open_Show(HDC DC, int x, int y)
>{
> char buf[BUFSIZ];
> FILE *fp;
> if((fp=fopen("c:\\pics\\mybmp.gif", "r+"))==NULL)
> {
> MessageBox(HWindow, "Can't open file!", "Error", MB_OK);
This function call indicates that your questions have to do with Windows
programming.
Quote:
> }
> fseek(fp, 776L, SEEK_END);
Rather bizarre seek to a magic position. A comment on what you expect this
to accomplish would be in order. Always check the return value of functions
that supply them. [OK, maybe not printf()].
Quote:
> fread(buf, sizeof(char), 1, fp);
You tried to read one [1] count-it "a" single, solitary character. You did
not check the status of the seek, or the status of the read. Since you have
no idea if either worked, what do you expect a sensible result to be?
Quote:
> fprintf(fp, "%c");
OK, where is the character you are trying to print, and why are you writing
it back to the file you read it from?
Quote:
>}
>Does anybody know what's wrong with this code?
0. Invest in a good lint. Or at least turn your compiler warnings on.
1. Post windows programming questions to windows newsgroups.
--
Hypertext C-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
C-FAQ ftp: ftp://rtfm.mit.edu, C-FAQ Book: ISBN 0-201-84519-9
Try "C Programming: A Modern Approach" ISBN 0-393-96945-2
Want Software? Algorithms? Pubs? http://www.infoseek.com