use length in your write as well as your read:
eg
[code=cpp]
fwrite(x, sizeof(x[0]), length, background);
[/code]
I have done this now and the image has still not been transferred. I opened the image in notepad to see if any more had been transferred than before. There are now 3 characters, before there was one.
I have done this now and the image has still not been transferred. I opened the image in notepad to see if any more had been transferred than before. There are now 3 characters, before there was one.
Have you tried printing out the intermediate variables.....
Is the length you get from fseek correct?
What is the size of x?
Can you narrow down whether the read or write is causing the error?
Have you tried printing out the intermediate variables.....
Is the length you get from fseek correct?
What is the size of x?
Can you narrow down whether the read or write is causing the error?
Lol I can't believe I missed that, sorry for being stupid. It printed: 101054
I have also just opened stbedes.jpg in notepad again. It appears that it has 4 characters but it seems to have a lot of spaces, and I would guess there are 101050 spaces because that would make up the rest of length and there are so many spaces that it is quite believable. Why is it coming up with 4 characters and 101050 spaces though?
Incidently (though I don't think this is the cause of your problem),
you are allocating WAY more memory than you need.....
you don't need to multiply (length* sizeof(int)) = the length is already the total number of bytes
Incidently (though I don't think this is the cause of your problem),
you are allocating WAY more memory than you need.....
you don't need to multiply (length* sizeof(int)) = the length is already the total number of bytes
Yes that's true.
However when u remove sizeof(int) final file will have size of 0 bytes,or atleast that's what happens to me.
Comment