From: "mikael-aronsson" <mikael-aronsson@telia.com>
To: linux-c-programming@vger.kernel.org
Subject: Re: fprintf() and duplicate IP addresses
Date: Tue, 31 May 2005 08:53:37 +0200 [thread overview]
Message-ID: <004101c565ad$7946fc50$b54be051@w128mtec> (raw)
In-Reply-To: d7h00u$q8r$1@sea.gmane.org
That's correct, most implementations use a static buffer, even though most
modern applications has a separate buffer for each thread.
Mikael
----- Original Message -----
From: "SVisor" <svisor@lycos.com>
To: <linux-c-programming@vger.kernel.org>
Sent: Tuesday, May 31, 2005 8:28 AM
Subject: Re: fprintf() and duplicate IP addresses
> M.Baris Demiray wrote:
>
> ...
>> addresses, if I use a single fprintf() they're printed as duplicates.
> ...
>> fprintf(stdout, "%s:%d -> %s:%d ", \
>> inet_ntoa(*(struct in_addr *)&ip_header->ip_src.s_addr), \
>> ntohs(tcp_header->source), \
>> inet_ntoa(*(struct in_addr *)&ip_header->ip_dst.s_addr), \
>> ntohs(tcp_header->dest));
>
> I have nothing to back my suspection with. But probably inet_ntoa(...)
> uses an internal buffer.
>
> printf( ) solves variables from the right, _before_ adding the result to
> the output (only the "pointer" to char* is saved), you only get the result
> from the first one (as they "point" to same memory).
>
> // Jarmo
>
> -
> To unsubscribe from this list: send the line "unsubscribe
> linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2005-05-31 6:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-31 2:19 fprintf() and duplicate IP addresses M.Baris Demiray
2005-05-31 6:28 ` SVisor
2005-05-31 6:53 ` mikael-aronsson [this message]
2005-06-02 9:11 ` M.Baris Demiray
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='004101c565ad$7946fc50$b54be051@w128mtec' \
--to=mikael-aronsson@telia.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.