954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

hex output of fwrite-ing char array

I am trying to find out how to replicate the output of fwrite("andbe", 4, 1, output);

an encryption algorithm I am using writes its output as this, but I am sending data across a network, and need to be able to write this to a string to send.

The algorithm writes all of its output in 4-byte chunks, and reads them the same way.

The problem is that it also writes strings that are much less than 16 characters as four bytes, which it can read with fread("...", 4, 1, input) but I cannot seem to replicate as just strings?

Is there a way to see what the fwrite would be writing/how it is padding the extra space?

Museless
Newbie Poster
1 post since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

try fprintf(fileHandle, "%04X", 156);

thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: