Re: How to display binary file contents if it is stored in an integer array?
- From: Chris Dollin <eh@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 01 May 2007 16:21:25 GMT
loudking wrote:
Well, what I actually mean is that the client is going to upload a
file to the server and the server will store the file content in the
memory. Later, the client will fetch the file from the server and
display it in stdout.
So the test script will be
./client add server test.pdf
./client fetch server > test_2.pdf
diff test.pdf test_2.pdf
So in my case, neither printf("%c") nor printf("%d") will work ...
You keep saying that, but you don't say why you think it's true.
int i;
for (i=0; i < integer_array_len; i++)
printf("%c", integer_array_val[i]);
Did you read Chris-Dollin-at-HP's reply? Because he points out that
if you write the wrong thing out, you'll get the wrong answer.
Try a simple test case first, for heavens sake. Make sure you can
write out zero bytes, one byte, two, three, four; five bytes, six
bytes, seven bytes, eight. At the moment your problem is nothing to
do with client-server communication: it's about rendering data to
the output.
Try some data like:
unsigned char someData[] =
{ 1, 2, 0, 17, 127, 128, 254, 255, 31, 32 };
and write it out with loops like:
for (i = 0; i < sizeof (someData); i += 1)
writeOutMyData( &someData[0], &someData[i] );
--
Signed And Sealed Hedgehog
Meaning precedes definition.
.
- References:
- Prev by Date: Re: How to display binary file contents if it is stored in an integer array?
- Next by Date: Re: How to display binary file contents if it is stored in an integer array?
- Previous by thread: Re: How to display binary file contents if it is stored in an integer array?
- Next by thread: Re: How to display binary file contents if it is stored in an integer array?
- Index(es):
Relevant Pages
|