Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Scientists will study your brain to learn more about your distant cousin, Man.


devel / comp.lang.c / skipping spaces in a sprintf format

SubjectAuthor
* skipping spaces in a sprintf formatLynn McGuire
`* Re: skipping spaces in a sprintf formatBart
 `* Re: skipping spaces in a sprintf formatManfred
  +- Re: skipping spaces in a sprintf formatBart
  +- Re: skipping spaces in a sprintf formatLynn McGuire
  `* Re: skipping spaces in a sprintf formatLynn McGuire
   `- Re: skipping spaces in a sprintf formatMike Terry

1
skipping spaces in a sprintf format

<tjhlc0$36ic6$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23541&group=comp.lang.c#23541

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: lynnmcgu...@gmail.com (Lynn McGuire)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: skipping spaces in a sprintf format
Date: Fri, 28 Oct 2022 17:33:36 -0500
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <tjhlc0$36ic6$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 28 Oct 2022 22:33:36 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="0c9b26242a76a994f7759d4c0c8332f7";
logging-data="3361158"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Zw4FIPkrAPH4H/e0oKjiM"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.4.0
Cancel-Lock: sha1:DJZhZ1JIAN+YJQivwE1ULNde/ow=
Content-Language: en-US
 by: Lynn McGuire - Fri, 28 Oct 2022 22:33 UTC

Is there any way to skip spaces in a sprintf format ? In Fortran, one
puts 10x to skip ten spaces.

I am using the following right now:

// WRITE (OUFILE,1700) current_page
// 1700 FORMAT (67X,'PAGE:',I8)
sprintf (termin1.outbuffer, "
PAGE:%8d", prglab1.current_page);
outwri (termin1.outbuffer);

Thanks,
Lynn

Re: skipping spaces in a sprintf format

<tjhm6m$i5g$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23542&group=comp.lang.c#23542

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!aioe.org!uabYU4OOdxBKlV2hpj27FQ.user.46.165.242.75.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: skipping spaces in a sprintf format
Date: Fri, 28 Oct 2022 23:47:50 +0100
Organization: Aioe.org NNTP Server
Message-ID: <tjhm6m$i5g$1@gioia.aioe.org>
References: <tjhlc0$36ic6$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="18608"; posting-host="uabYU4OOdxBKlV2hpj27FQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.4.0
X-Notice: Filtered by postfilter v. 0.9.2
 by: Bart - Fri, 28 Oct 2022 22:47 UTC

On 28/10/2022 23:33, Lynn McGuire wrote:
> Is there any way to skip spaces in a sprintf format ?  In Fortran, one
> puts 10x to skip ten spaces.
>
> I am using the following right now:
>
>     // WRITE (OUFILE,1700) current_page
>     // 1700    FORMAT (67X,'PAGE:',I8)
>    sprintf (termin1.outbuffer, "                           PAGE:%8d",
> prglab1.current_page);
>    outwri (termin1.outbuffer);
>
> Thanks,
> Lynn

This prints a string within a field of 10 spaces:

printf("<%*s>\n",10,"");

"*" is used for a variable field width, padded on the left. "%-*s" will
pad on the right.

Re: skipping spaces in a sprintf format

<tjhpia$1jgr$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23543&group=comp.lang.c#23543

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!aioe.org!Be2tmgKbrUiSvvT25/KcFg.user.46.165.242.75.POSTED!not-for-mail
From: non...@add.invalid (Manfred)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: skipping spaces in a sprintf format
Date: Sat, 29 Oct 2022 01:45:13 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tjhpia$1jgr$1@gioia.aioe.org>
References: <tjhlc0$36ic6$1@dont-email.me> <tjhm6m$i5g$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="52763"; posting-host="Be2tmgKbrUiSvvT25/KcFg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.4.1
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Manfred - Fri, 28 Oct 2022 23:45 UTC

On 10/29/2022 12:47 AM, Bart wrote:
> On 28/10/2022 23:33, Lynn McGuire wrote:
>> Is there any way to skip spaces in a sprintf format ?  In Fortran, one
>> puts 10x to skip ten spaces.
>>
>> I am using the following right now:
>>
>>      // WRITE (OUFILE,1700) current_page
>>      // 1700    FORMAT (67X,'PAGE:',I8)
>>     sprintf (termin1.outbuffer, "                           PAGE:%8d",
>> prglab1.current_page);
>>     outwri (termin1.outbuffer);
>>
>> Thanks,
>> Lynn
>
> This prints a string within a field of 10 spaces:
>
>     printf("<%*s>\n",10,"");
>
> "*" is used for a variable field width, padded on the left. "%-*s" will
> pad on the right.
>
>

Simpler, and probably closer to what the OP needs:

sprintf (termin1.outbuffer, "%32s%8d", "PAGE:", prglab1.current_page);
outwri (termin1.outbuffer);

Re: skipping spaces in a sprintf format

<tjiu2v$12u5$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23544&group=comp.lang.c#23544

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!news.nntp4.net!aioe.org!uabYU4OOdxBKlV2hpj27FQ.user.46.165.242.75.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: skipping spaces in a sprintf format
Date: Sat, 29 Oct 2022 11:08:30 +0100
Organization: Aioe.org NNTP Server
Message-ID: <tjiu2v$12u5$1@gioia.aioe.org>
References: <tjhlc0$36ic6$1@dont-email.me> <tjhm6m$i5g$1@gioia.aioe.org>
<tjhpia$1jgr$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="35781"; posting-host="uabYU4OOdxBKlV2hpj27FQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.4.0
X-Notice: Filtered by postfilter v. 0.9.2
 by: Bart - Sat, 29 Oct 2022 10:08 UTC

On 29/10/2022 00:45, Manfred wrote:
> On 10/29/2022 12:47 AM, Bart wrote:
>> On 28/10/2022 23:33, Lynn McGuire wrote:
>>> Is there any way to skip spaces in a sprintf format ?  In Fortran,
>>> one puts 10x to skip ten spaces.
>>>
>>> I am using the following right now:
>>>
>>>      // WRITE (OUFILE,1700) current_page
>>>      // 1700    FORMAT (67X,'PAGE:',I8)
>>>     sprintf (termin1.outbuffer, "
>>> PAGE:%8d", prglab1.current_page);
>>>     outwri (termin1.outbuffer);
>>>
>>> Thanks,
>>> Lynn
>>
>> This prints a string within a field of 10 spaces:
>>
>>      printf("<%*s>\n",10,"");
>>
>> "*" is used for a variable field width, padded on the left. "%-*s"
>> will pad on the right.
>>
>>
>
> Simpler, and probably closer to what the OP needs:
>
> sprintf (termin1.outbuffer, "%32s%8d", "PAGE:", prglab1.current_page);
> outwri (termin1.outbuffer);

I thought I'd missed the obvious solution..

Re: skipping spaces in a sprintf format

<tjjtce$9nd$2@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23548&group=comp.lang.c#23548

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!aioe.org!mdf2aNOb2oCHynmZpuX5uw.user.46.165.242.91.POSTED!not-for-mail
From: lynnmcgu...@gmail.com (Lynn McGuire)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: skipping spaces in a sprintf format
Date: Sat, 29 Oct 2022 14:02:37 -0500
Organization: Aioe.org NNTP Server
Message-ID: <tjjtce$9nd$2@gioia.aioe.org>
References: <tjhlc0$36ic6$1@dont-email.me> <tjhm6m$i5g$1@gioia.aioe.org>
<tjhpia$1jgr$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="9965"; posting-host="mdf2aNOb2oCHynmZpuX5uw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.4.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Lynn McGuire - Sat, 29 Oct 2022 19:02 UTC

On 10/28/2022 6:45 PM, Manfred wrote:
> On 10/29/2022 12:47 AM, Bart wrote:
>> On 28/10/2022 23:33, Lynn McGuire wrote:
>>> Is there any way to skip spaces in a sprintf format ?  In Fortran,
>>> one puts 10x to skip ten spaces.
>>>
>>> I am using the following right now:
>>>
>>>      // WRITE (OUFILE,1700) current_page
>>>      // 1700    FORMAT (67X,'PAGE:',I8)
>>>     sprintf (termin1.outbuffer, "
>>> PAGE:%8d", prglab1.current_page);
>>>     outwri (termin1.outbuffer);
>>>
>>> Thanks,
>>> Lynn
>>
>> This prints a string within a field of 10 spaces:
>>
>>      printf("<%*s>\n",10,"");
>>
>> "*" is used for a variable field width, padded on the left. "%-*s"
>> will pad on the right.
>>
>>
>
> Simpler, and probably closer to what the OP needs:
>
> sprintf (termin1.outbuffer, "%32s%8d", "PAGE:", prglab1.current_page);
> outwri (termin1.outbuffer);

Thank you both !

Lynn

Re: skipping spaces in a sprintf format

<1b736896-c85f-8ef9-3c4c-63c2fd4f755c@gmail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23552&group=comp.lang.c#23552

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!aioe.org!mdf2aNOb2oCHynmZpuX5uw.user.46.165.242.91.POSTED!not-for-mail
From: lynnmcgu...@gmail.com (Lynn McGuire)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: skipping spaces in a sprintf format
Date: Sat, 29 Oct 2022 15:55:19 -0500
Organization: Aioe.org NNTP Server
Message-ID: <1b736896-c85f-8ef9-3c4c-63c2fd4f755c@gmail.com>
References: <tjhlc0$36ic6$1@dont-email.me> <tjhm6m$i5g$1@gioia.aioe.org>
<tjhpia$1jgr$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="38761"; posting-host="mdf2aNOb2oCHynmZpuX5uw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.4.1
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Lynn McGuire - Sat, 29 Oct 2022 20:55 UTC

On 10/28/2022 6:45 PM, Manfred wrote:
> On 10/29/2022 12:47 AM, Bart wrote:
>> On 28/10/2022 23:33, Lynn McGuire wrote:
>>> Is there any way to skip spaces in a sprintf format ?  In Fortran,
>>> one puts 10x to skip ten spaces.
>>>
>>> I am using the following right now:
>>>
>>>      // WRITE (OUFILE,1700) current_page
>>>      // 1700    FORMAT (67X,'PAGE:',I8)
>>>     sprintf (termin1.outbuffer, "
>>> PAGE:%8d", prglab1.current_page);
>>>     outwri (termin1.outbuffer);
>>>
>>> Thanks,
>>> Lynn
>>
>> This prints a string within a field of 10 spaces:
>>
>>      printf("<%*s>\n",10,"");
>>
>> "*" is used for a variable field width, padded on the left. "%-*s"
>> will pad on the right.
>>
>>
>
> Simpler, and probably closer to what the OP needs:
>
> sprintf (termin1.outbuffer, "%32s%8d", "PAGE:", prglab1.current_page);
> outwri (termin1.outbuffer);

Or,

sprintf (termin1.outbuffer, "%66sPAGE:%8d", " ", prglab1.current_page);
outwri (termin1.outbuffer);

Thanks !

Lynn

Re: skipping spaces in a sprintf format

<tjk60e$1unm$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23553&group=comp.lang.c#23553

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!aioe.org!u34rtCtuoQ08aR/5G1IYuw.user.46.165.242.75.POSTED!not-for-mail
From: news.dea...@darjeeling.plus.com (Mike Terry)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: skipping spaces in a sprintf format
Date: Sat, 29 Oct 2022 22:29:50 +0100
Organization: Aioe.org NNTP Server
Message-ID: <tjk60e$1unm$1@gioia.aioe.org>
References: <tjhlc0$36ic6$1@dont-email.me> <tjhm6m$i5g$1@gioia.aioe.org>
<tjhpia$1jgr$1@gioia.aioe.org>
<1b736896-c85f-8ef9-3c4c-63c2fd4f755c@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="64246"; posting-host="u34rtCtuoQ08aR/5G1IYuw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
Firefox/68.0 SeaMonkey/2.53.12
X-Notice: Filtered by postfilter v. 0.9.2
 by: Mike Terry - Sat, 29 Oct 2022 21:29 UTC

On 29/10/2022 21:55, Lynn McGuire wrote:
> On 10/28/2022 6:45 PM, Manfred wrote:
>> On 10/29/2022 12:47 AM, Bart wrote:
>>> On 28/10/2022 23:33, Lynn McGuire wrote:
>>>> Is there any way to skip spaces in a sprintf format ?  In Fortran, one puts 10x to skip ten spaces.
>>>>
>>>> I am using the following right now:
>>>>
>>>>      // WRITE (OUFILE,1700) current_page
>>>>      // 1700    FORMAT (67X,'PAGE:',I8)
>>>>     sprintf (termin1.outbuffer, " PAGE:%8d", prglab1.current_page);
>>>>     outwri (termin1.outbuffer);
>>>>
>>>> Thanks,
>>>> Lynn
>>>
>>> This prints a string within a field of 10 spaces:
>>>
>>>      printf("<%*s>\n",10,"");
>>>
>>> "*" is used for a variable field width, padded on the left. "%-*s" will pad on the right.
>>>
>>>
>>
>> Simpler, and probably closer to what the OP needs:
>>
>> sprintf (termin1.outbuffer, "%32s%8d", "PAGE:", prglab1.current_page);
>> outwri (termin1.outbuffer);
>
> Or,
>
>   sprintf (termin1.outbuffer, "%66sPAGE:%8d", " ", prglab1.current_page);
>   outwri (termin1.outbuffer);
>

I'd suggest a minor improvement: ..."%66sPage:%8d", "",...

Looking at:
printf ("==%0s==\n", " ");
printf ("==%0s==\n", "");
We get output
== ==
====

So I could say the empty string works more universally, and SAVES A BYTE OF DISK SPACE!!! :) Well,
probably you would never want to skip 0 spaces, but hey... (it can't be bad to handle edge cases,
even if you're convinced you'll never use them.)

Mike.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor