Re: iovecs don't print right
- From: jt@xxxxxxxxxxx (Jens Thoms Toerring)
- Date: 5 Jul 2008 14:08:46 GMT
nobody+cplusplus <nobody@xxxxxxxxxxxxxxxx> wrote:
nobody+cplusplus wrote:
Stephane CHAZELAS wrote:
2008-07-05, 03:51(+09), nobody+cplusplus:
[...]
printf ("len %d, %d: %s \n", (int) iov[i].iov_len, i, (char *) \[...]
iov[i].iov_base );
What wrong am i doing here? :/[...]
You're using printf("%s") on something that is not a
zero-terminated string.
FYI, hence (void*)->(char*) for iov[i].iov_base
anything else?
FYI, casting doesn't append the required terminating '\0' character.
A char array isn't a string per se, only if one of the chars is '\0'
it's also a string.
OK somehow using printf("%.<precision>s",..) does the trick (as the max
characters is 16, <precision> = 16. But this is a ugly hack at best. Is
there better way of doing it?
Why should that be an "ugly hack"? If you don't have a string you
can't use printf() with "%s" otherwise. But you shouldn't use 16 but
the number of bytes you received (use "%*s" and put the number of
bytes you read into the arguments before the char array). Or append
the required '\0' char to make it a string.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@xxxxxxxxxxx
\__________________________ http://toerring.de
.
- References:
- iovecs don't print right
- From: nobody+cplusplus
- Re: iovecs don't print right
- From: Stephane CHAZELAS
- Re: iovecs don't print right
- From: nobody+cplusplus
- Re: iovecs don't print right
- From: nobody+cplusplus
- iovecs don't print right
- Prev by Date: Traceroute using IP option
- Next by Date: Re: Debugging an exec'ed process
- Previous by thread: Re: iovecs don't print right
- Next by thread: Re: iovecs don't print right
- Index(es):
Relevant Pages
|