Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 11th, 2006, 12:07 AM   #1
zl0h
Newbie
 
Join Date: Nov 2006
Posts: 4
Rep Power: 0 zl0h is on a distinguished road
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
zl0h is offline   Reply With Quote
Old Nov 11th, 2006, 3:06 AM   #2
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 894
Rep Power: 4 The Dark is on a distinguished road
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.
The Dark is offline   Reply With Quote
Old Nov 11th, 2006, 4:07 AM   #3
zl0h
Newbie
 
Join Date: Nov 2006
Posts: 4
Rep Power: 0 zl0h is on a distinguished road
The "wb" works! Thanks so much dude, was desperating of this! Made me happy. =)
zl0h is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:38 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC