Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #64744 > unrolled thread

sprintf and the trailing null

Started by"Rick C. Hodgin" <rick.c.hodgin@gmail.com>
First post2015-07-06 06:16 -0700
Last post2015-07-07 21:48 -0500
Articles 10 on this page of 70 — 20 participants

Back to article view | Back to comp.lang.c


Contents

  sprintf and the trailing null "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-06 06:16 -0700
    Re: sprintf and the trailing null John McCue <jmccue@jmcnet1.bstnma.east.verizon.net> - 2015-07-06 13:30 +0000
      Re: sprintf and the trailing null "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-06 06:37 -0700
        Re: sprintf and the trailing null Reinhardt Behm <rbehm@hushmail.com> - 2015-07-06 21:58 +0800
          Re: sprintf and the trailing null "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-06 07:12 -0700
            Re: sprintf and the trailing null Reinhardt Behm <rbehm@hushmail.com> - 2015-07-06 22:34 +0800
              Re: sprintf and the trailing null "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-06 08:44 -0700
            Re: sprintf and the trailing null Bartc <bc@freeuk.com> - 2015-07-06 15:46 +0100
              Re: sprintf and the trailing null Keith Thompson <kst-u@mib.org> - 2015-07-06 08:06 -0700
                Re: sprintf and the trailing null Bartc <bc@freeuk.com> - 2015-07-06 17:42 +0100
                  Re: sprintf and the trailing null "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-06 09:48 -0700
                  Re: sprintf and the trailing null Bartc <bc@freeuk.com> - 2015-07-06 18:07 +0100
                    Re: sprintf and the trailing null Martin Shobe <martin.shobe@yahoo.com> - 2015-07-06 12:40 -0500
                  Re: sprintf and the trailing null Keith Thompson <kst-u@mib.org> - 2015-07-06 10:46 -0700
                    Re: sprintf and the trailing null Bartc <bc@freeuk.com> - 2015-07-06 18:58 +0100
            Re: sprintf and the trailing null Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-07-06 16:38 +0100
              Re: sprintf and the trailing null Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-07-06 23:44 +0100
                Re: sprintf and the trailing null "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-06 15:48 -0700
                Re: sprintf and the trailing null Phil Carmody <pc+usenet@asdf.org> - 2015-07-08 20:09 +0300
                  Re: sprintf and the trailing null "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-08 10:11 -0700
                    Re: sprintf and the trailing null Bartc <bc@freeuk.com> - 2015-07-08 19:01 +0100
                      Re: sprintf and the trailing null David Kleinecke <dkleinecke@gmail.com> - 2015-07-09 09:02 -0700
                        Re: sprintf and the trailing null Richard Heathfield <rjh@cpax.org.uk> - 2015-07-09 17:07 +0100
                          Re: sprintf and the trailing null Phil Carmody <pc+usenet@asdf.org> - 2015-07-10 17:06 +0300
                        Re: sprintf and the trailing null glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-07-09 17:42 +0000
                      Re: sprintf and the trailing null Phil Carmody <pc+usenet@asdf.org> - 2015-07-10 13:33 +0300
                        Re: sprintf and the trailing null Bartc <bc@freeuk.com> - 2015-07-10 12:09 +0100
                          Re: sprintf and the trailing null Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-07-10 04:51 -0700
                            Re: sprintf and the trailing null Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-07-10 17:24 +0100
                          Re: sprintf and the trailing null Keith Thompson <kst-u@mib.org> - 2015-07-10 08:33 -0700
                  Re: sprintf and the trailing null Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-11 04:58 -0700
        Re: sprintf and the trailing null jt@toerring.de (Jens Thoms Toerring) - 2015-07-06 14:15 +0000
          Re: sprintf and the trailing null "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-06 07:20 -0700
            Re: sprintf and the trailing null raltbos@xs4all.nl (Richard Bos) - 2015-07-06 19:54 +0000
              Re: sprintf and the trailing null "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-06 13:31 -0700
                Re: sprintf and the trailing null Richard Heathfield <rjh@cpax.org.uk> - 2015-07-06 21:52 +0100
                Re: sprintf and the trailing null raltbos@xs4all.nl (Richard Bos) - 2015-07-06 22:52 +0000
                  Re: sprintf and the trailing null Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-07-07 01:04 +0100
                  Re: sprintf and the trailing null Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-07-06 19:13 -0700
                    Re: sprintf and the trailing null Reinhardt Behm <rbehm@hushmail.com> - 2015-07-07 12:45 +0800
                      Re: sprintf and the trailing null Rosario19 <Ros@invalid.invalid> - 2015-07-07 10:15 +0200
                    Re: sprintf and the trailing null Bartc <bc@freeuk.com> - 2015-07-07 10:31 +0100
                      Re: sprintf and the trailing null Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-07-07 02:51 -0700
                        Re: sprintf and the trailing null Bartc <bc@freeuk.com> - 2015-07-07 12:10 +0100
                          Re: sprintf and the trailing null Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-07-07 05:08 -0700
                            Re: sprintf and the trailing null Bartc <bc@freeuk.com> - 2015-07-07 13:52 +0100
                              Re: sprintf and the trailing null Phil Carmody <pc+usenet@asdf.org> - 2015-07-08 20:20 +0300
                                Re: sprintf and the trailing null Bartc <bc@freeuk.com> - 2015-07-08 18:51 +0100
                                Re: sprintf and the trailing null raltbos@xs4all.nl (Richard Bos) - 2015-07-09 10:27 +0000
                            Re: sprintf and the trailing null Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-10 19:03 -0700
                Re: sprintf and the trailing null gordonb.7tw58@burditt.org (Gordon Burditt) - 2015-07-07 15:40 -0500
                  Re: sprintf and the trailing null "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-07 15:14 -0700
          Re: sprintf and the trailing null "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-06 07:27 -0700
            Re: sprintf and the trailing null jt@toerring.de (Jens Thoms Toerring) - 2015-07-06 16:46 +0000
          Re: sprintf and the trailing null Keith Thompson <kst-u@mib.org> - 2015-07-06 07:56 -0700
    Re: sprintf and the trailing null Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2015-07-06 09:32 -0600
    Re: sprintf and the trailing null Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-07-06 08:37 -0700
      Re: sprintf and the trailing null Keith Thompson <kst-u@mib.org> - 2015-07-06 08:54 -0700
    Re: sprintf and the trailing null "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-06 08:53 -0700
      Re: sprintf and the trailing null "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-06 09:00 -0700
      Re: sprintf and the trailing null Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-07-06 17:14 +0100
        Re: sprintf and the trailing null "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-06 09:24 -0700
          Re: sprintf and the trailing null "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-06 09:31 -0700
    Re: sprintf and the trailing null Sjouke Burry <burrynulnulfour@ppllaanneett.nnll> - 2015-07-07 01:43 +0200
      Re: sprintf and the trailing null "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-06 17:09 -0700
        Re: sprintf and the trailing null Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2015-07-06 21:08 -0600
          Re: sprintf and the trailing null "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-06 21:29 -0700
          Re: sprintf and the trailing null Phil Carmody <pc+usenet@asdf.org> - 2015-07-08 20:24 +0300
            Re: sprintf and the trailing null "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-08 10:44 -0700
    Re: sprintf and the trailing null Les Cargill <lcargill99@comcast.com> - 2015-07-07 21:48 -0500

Page 4 of 4 — ← Prev page 1 2 3 [4]


#64772

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2015-07-06 17:14 +0100
Message-ID<87y4ittgad.fsf@bsb.me.uk>
In reply to#64768
"Rick C. Hodgin" <rick.c.hodgin@gmail.com> writes:
<snip>
> I think I will just write my own.  I'll have to eventually anyway.
>
> I don't use the full set of printf format specifiers, and will add
> the ones I need as they come up.  I've also always had a dream of
> using sprintf(buffer, "%3s", "abcdef"); and having it only copy
> three characters, but I think I saw today in a google search where
> using sprintf(buffer, "%.*s", 3, "abcdef"); would work. I like that,
> but would prefer the %3s syntax.

That syntax already means something, so you are ditching an existing
meaning to get the one you want.  Obviously, for you own provate
language the choice is yours, but it would be a bad choice for something
that people familiar with C (or any other language that shares C's
printf specifiers) would have to learn.  (And that's a lot of people!)

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#64773

From"Rick C. Hodgin" <rick.c.hodgin@gmail.com>
Date2015-07-06 09:24 -0700
Message-ID<3fc249c2-cf16-4634-8565-10252688bf92@googlegroups.com>
In reply to#64772
On Monday, July 6, 2015 at 12:14:11 PM UTC-4, Ben Bacarisse wrote:
> "Rick C. Hodgin" <rick.c.hodgin@gmail.com> writes:
> <snip>
> > I think I will just write my own.  I'll have to eventually anyway.
> >
> > I don't use the full set of printf format specifiers, and will add
> > the ones I need as they come up.  I've also always had a dream of
> > using sprintf(buffer, "%3s", "abcdef"); and having it only copy
> > three characters, but I think I saw today in a google search where
> > using sprintf(buffer, "%.*s", 3, "abcdef"); would work. I like that,
> > but would prefer the %3s syntax.
> 
> That syntax already means something, so you are ditching an existing
> meaning to get the one you want.  Obviously, for you own provate
> language the choice is yours, but it would be a bad choice for something
> that people familiar with C (or any other language that shares C's
> printf specifiers) would have to learn.  (And that's a lot of people!)

What does "%3s" already mean?  When I use it it just appears to ignore
the 3 and do a %s.

Best regards,
Rick C. Hodgin

[toc] | [prev] | [next] | [standalone]


#64774

From"Rick C. Hodgin" <rick.c.hodgin@gmail.com>
Date2015-07-06 09:31 -0700
Message-ID<08fb9080-1cc0-4a19-a074-b1d1a59119a3@googlegroups.com>
In reply to#64773
On Monday, July 6, 2015 at 12:24:25 PM UTC-4, Rick C. Hodgin wrote:
> On Monday, July 6, 2015 at 12:14:11 PM UTC-4, Ben Bacarisse wrote:
> > "Rick C. Hodgin" <rick.c.hodgin@gmail.com> writes:
> > <snip>
> > > I think I will just write my own.  I'll have to eventually anyway.
> > >
> > > I don't use the full set of printf format specifiers, and will add
> > > the ones I need as they come up.  I've also always had a dream of
> > > using sprintf(buffer, "%3s", "abcdef"); and having it only copy
> > > three characters, but I think I saw today in a google search where
> > > using sprintf(buffer, "%.*s", 3, "abcdef"); would work. I like that,
> > > but would prefer the %3s syntax.
> > 
> > That syntax already means something, so you are ditching an existing
> > meaning to get the one you want.  Obviously, for you own provate
> > language the choice is yours, but it would be a bad choice for something
> > that people familiar with C (or any other language that shares C's
> > printf specifiers) would have to learn.  (And that's a lot of people!)
> 
> What does "%3s" already mean?  When I use it it just appears to ignore
> the 3 and do a %s.

On this page:

    http://www.cplusplus.com/reference/cstdio/printf/

...I see that it indicates the minimum number of characters to print.
Okay.  I've used that with numbers, but never with a string.  I can
use the %.3s syntax for explicit copy width.

Best regards,
Rick C. Hodgin

[toc] | [prev] | [next] | [standalone]


#64814

FromSjouke Burry <burrynulnulfour@ppllaanneett.nnll>
Date2015-07-07 01:43 +0200
Message-ID<559b1298$0$21122$703f8584@textnews.kpn.nl>
In reply to#64744
On 06.07.15 15:16, Rick C. Hodgin wrote:
> Two questions:
>
>    (1) Is there a version of sprintf() without a trailing NULL?
>    (2) Why does sprintf() automatically insert a trailing NULL?
>
> TYIA!
>
> Best regards,
> Rick C. Hodgin
>
Look at the definition of a string.
sprintf produces a string, with all the trimmings needed for a string.
What is it you dont understand about strings?

[toc] | [prev] | [next] | [standalone]


#64818

From"Rick C. Hodgin" <rick.c.hodgin@gmail.com>
Date2015-07-06 17:09 -0700
Message-ID<96fb2f5a-8410-409b-84c2-1f85e75fb754@googlegroups.com>
In reply to#64814
Sjouke Burry wrote:
> Rick C. Hodgin wrote:
>> Two questions:
>>     (1) Is there a version of sprintf() without a trailing NULL?
>>     (2) Why does sprintf() automatically insert a trailing NULL?
>> TYIA!
>> Best regards,
>> Rick C. Hodgin
>
> Look at the definition of a string. sprintf
> produces a string, with all the trimmings
> needed for a string. What is it you don't
> understand about strings?

Multi-threading.

Best regards,
Rick C. Hodgin

[toc] | [prev] | [next] | [standalone]


#64823

FromJoe Pfeiffer <pfeiffer@cs.nmsu.edu>
Date2015-07-06 21:08 -0600
Message-ID<1bzj38wtp6.fsf@pfeifferfamily.net>
In reply to#64818
"Rick C. Hodgin" <rick.c.hodgin@gmail.com> writes:

> Sjouke Burry wrote:
>> Rick C. Hodgin wrote:
>>> Two questions:
>>>     (1) Is there a version of sprintf() without a trailing NULL?
>>>     (2) Why does sprintf() automatically insert a trailing NULL?
>>> TYIA!
>>> Best regards,
>>> Rick C. Hodgin
>>
>> Look at the definition of a string. sprintf
>> produces a string, with all the trimmings
>> needed for a string. What is it you don't
>> understand about strings?
>
> Multi-threading.

I've got *no* idea what your no-trailing-zero strings have to do with
multi-threading...  explain, please?

[toc] | [prev] | [next] | [standalone]


#64829

From"Rick C. Hodgin" <rick.c.hodgin@gmail.com>
Date2015-07-06 21:29 -0700
Message-ID<0f6f43c9-c5bd-4151-8f80-072ac7c9540e@googlegroups.com>
In reply to#64823
Joe Pfeiffer wrote:
> I've got *no* idea what your no-trailing-zero
> strings have to do with multi-threading...
> explain, please?
 
It loses something when explained. But... string,
threads... Threads make up a string... Multi-threading...
like sewing threads, combined into a string, something
you might use to play with the cat, or hold some
meat from the butcher wrapped up.

Humor. It loses something when explained.

Best regards,
Rick C. Hodgin

[toc] | [prev] | [next] | [standalone]


#64937

FromPhil Carmody <pc+usenet@asdf.org>
Date2015-07-08 20:24 +0300
Message-ID<87r3oid0lk.fsf@bazspaz.fatphil.org>
In reply to#64823
Joe Pfeiffer <pfeiffer@cs.nmsu.edu> writes:
> "Rick C. Hodgin" <rick.c.hodgin@gmail.com> writes:
> > Sjouke Burry wrote:
> >> Rick C. Hodgin wrote:
> >>> Two questions:
> >>>     (1) Is there a version of sprintf() without a trailing NULL?
> >>>     (2) Why does sprintf() automatically insert a trailing NULL?
> >>> TYIA!
> >>> Best regards,
> >>> Rick C. Hodgin
> >>
> >> Look at the definition of a string. sprintf
> >> produces a string, with all the trimmings
> >> needed for a string. What is it you don't
> >> understand about strings?
> >
> > Multi-threading.
> 
> I've got *no* idea what your no-trailing-zero strings have to do with
> multi-threading...  explain, please?

Like you, I'm stranded.

Phil, avoiding the "a frayed knot" pun.
-- 
A well regulated militia, being necessary to the security of a free state,
the right of the people to keep and bear arms, shall be well regulated.

[toc] | [prev] | [next] | [standalone]


#64943

From"Rick C. Hodgin" <rick.c.hodgin@gmail.com>
Date2015-07-08 10:44 -0700
Message-ID<bea27e92-5a40-49b6-b86b-cecfbda9ae52@googlegroups.com>
In reply to#64937
On Wednesday, July 8, 2015 at 1:24:16 PM UTC-4, Phil Carmody wrote:
> Joe Pfeiffer <pfeiffer@cs.nmsu.edu> writes:
> > "Rick C. Hodgin" <rick.c.hodgin@gmail.com> writes:
> > > Sjouke Burry wrote:
> > >> Rick C. Hodgin wrote:
> > >>> Two questions:
> > >>>     (1) Is there a version of sprintf() without a trailing NULL?
> > >>>     (2) Why does sprintf() automatically insert a trailing NULL?
> > >>> TYIA!
> > >>> Best regards,
> > >>> Rick C. Hodgin
> > >>
> > >> Look at the definition of a string. sprintf
> > >> produces a string, with all the trimmings
> > >> needed for a string. What is it you don't
> > >> understand about strings?
> > >
> > > Multi-threading.
> > 
> > I've got *no* idea what your no-trailing-zero strings have to do with
> > multi-threading...  explain, please?
> 
> Like you, I'm stranded.
> 
> Phil, avoiding the "a frayed knot" pun.

LOL!

Best regards,
Rick C. Hodgin

[toc] | [prev] | [next] | [standalone]


#64889

FromLes Cargill <lcargill99@comcast.com>
Date2015-07-07 21:48 -0500
Message-ID<mni2us$efa$1@dont-email.me>
In reply to#64744
Rick C. Hodgin wrote:
> Two questions:
>
>    (1) Is there a version of sprintf() without a trailing NULL?
>    (2) Why does sprintf() automatically insert a trailing NULL?
>
> TYIA!
>
> Best regards,
> Rick C. Hodgin
>

(1) No.
(2) Because the verb "sprintf" starts with "s" and this is 'C'.

-- 
Les Cargill

[toc] | [prev] | [standalone]


Page 4 of 4 — ← Prev page 1 2 3 [4]

Back to top | Article view | comp.lang.c


csiph-web