![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Nov 2006
Posts: 4
Rep Power: 0
![]() |
Weird additional bytes
I got a file included as byte array in my c application and write that to a file like this:
FILE *out, *fopen();
out = fopen("test.dll","w");
int i = 0;
while(i < TESTSTUB_LEN)
{
fputc(TEST_STUB[i], out);
i++;
}
fclose(out);So that actually works well, the problem is just that it adds 3229 for some reason. Original file: 818176 bytes New written file: 821405 bytes I checked the byte array, it's correct. Would be awesome if anyone was able to help me out Thank you zl0h |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 894
Rep Power: 4
![]() |
Is TESTSTUB_LEN equal to 818176? It is impossible to tell from the snippet of your code. If it is 818176 and you are under Windows, then you might be falling foul of the text mode output translating LFs (line feed) into CRLF (carriage return - line feed) pairs.
Try changing the fopen call to use "wb" instead of "w", that will put the output file into binary mode. |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Nov 2006
Posts: 4
Rep Power: 0
![]() |
The "wb" works! Thanks so much dude, was desperating of this! Made me happy. =)
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ackerman's function - crash upon launch | codylee270 | C++ | 6 | Oct 19th, 2006 3:14 AM |
| double functions (getting weird numbers) | j0nathan | C++ | 4 | Apr 5th, 2006 3:53 AM |
| weird problem with find(Redhat 9) | InfoGeek | Coder's Corner Lounge | 12 | Jan 12th, 2006 11:56 AM |
| weird output in my server program | nindoja | C++ | 21 | Nov 24th, 2005 10:31 AM |
| Need help building number from bytes | jloyd | Other Programming Languages | 4 | Oct 18th, 2005 9:43 AM |