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


Groups > comp.os.os2.programmer.misc > #1637

Re: C: How to convert a \0 char into a dot for printf output?

Path csiph.com!news.mixmin.net!weretis.net!feeder4.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From nospam_2018@efbe.prima.de
Newsgroups comp.os.os2.programmer.misc
Subject Re: C: How to convert a \0 char into a dot for printf output?
Date Mon, 21 May 2018 22:56:57 +0200
Lines 39
Message-ID <fmgq4pF6g04U1@mid.individual.net> (permalink)
References <pdmv2q$uo1$1@news.albasani.net> <rs6dnUv6aIFYkWLHnZ2dnUU7-dGdnZ2d@giganews.com> <pdn2s2$9hh$1@news.albasani.net> <pdn9j2$ff9$1@solani.org> <pdp5c1$hr6$1@news.albasani.net> <pdp8tq$8hb$1@news.albasani.net> <11p86vVJT4Oe-pn2-le11Ozv52zBR@slamain> <pdpice$eld$1@news.albasani.net> <pdrmmc$fhp$1@news.albasani.net> <fmdo8oFg9geU1@mid.individual.net> <pdspef$jj$1@news.albasani.net>
Reply-To fbeythien@gmx.de
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
X-Trace individual.net TcVNG4gZqpFQdhPzJN/9AwTdbeDH8f7/IvkC9YEG7UdGME+Jg=
Cancel-Lock sha1:vCtZ49b0GYk5wvKYOxJoHz/ZmUI=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0
In-Reply-To <pdspef$jj$1@news.albasani.net>
Content-Language de-DE
Xref csiph.com comp.os.os2.programmer.misc:1637

Show key headers only | View raw


Am 20.05.2018 um 23:30 schrieb Andreas Schnellbacher:

Hi Andreas,

> 
> Thanks, Frank. That was the info I was looking for.
> 
> BTW: Do you also have an idea, how to get it copied? (I guess with
> memcpy.)

Yes, but to use memcpy, you need the length. This can be calculated by a
variation of Lars code: untested


static int zerolength( PSZ pszzString)
{
         PSZ            p = pszzString;

   if (p != NULL)
      {
      while ((*p != 0) || (*(p+1) != 0)) // !a || !b == !(a && b)
         {

         p++;


         }
         return (p +1 - pszzString); // calculate length
      }
   else
      {
          return 0; // length is zero
      }
}

Now you can use the returned length for malloc and memcpy.

CU/2
Frank

Back to comp.os.os2.programmer.misc | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

C: How to convert a \0 char into a dot for printf output? Andreas Schnellbacher <aschn@despammed.com> - 2018-05-18 18:30 +0200
  Re: C: How to convert a \0 char into a dot for printf output? James Moe <jimoeDESPAM@sohnen-moe.com> - 2018-05-18 10:26 -0700
    Re: C: How to convert a \0 char into a dot for printf output? Andreas Schnellbacher <aschn@despammed.com> - 2018-05-18 19:34 +0200
      Re: C: How to convert a \0 char into a dot for printf output? Lars Erdmann <lars.erdmann@arcor.de> - 2018-05-18 21:29 +0200
        Re: C: How to convert a \0 char into a dot for printf output? Andreas Schnellbacher <aschn@despammed.com> - 2018-05-19 14:29 +0200
          Re: C: How to convert a \0 char into a dot for printf output? Andreas Schnellbacher <aschn@despammed.com> - 2018-05-19 15:30 +0200
            Re: C: How to convert a \0 char into a dot for printf output? "Steven Levine" <steve53@nomail.earthlink.net> - 2018-05-19 09:43 -0500
              Re: C: How to convert a \0 char into a dot for printf output? Andreas Schnellbacher <aschn@despammed.com> - 2018-05-19 18:11 +0200
                Re: C: How to convert a \0 char into a dot for printf output? Andreas Schnellbacher <aschn@despammed.com> - 2018-05-20 13:37 +0200
                Re: C: How to convert a \0 char into a dot for printf output? Peter Flass <peter_flass@yahoo.com> - 2018-05-20 10:36 -0400
                Re: C: How to convert a \0 char into a dot for printf output? "Steven Levine" <steve53@nomail.earthlink.net> - 2018-05-20 10:49 -0500
                Re: C: How to convert a \0 char into a dot for printf output? Andreas Schnellbacher <aschn@despammed.com> - 2018-05-20 18:46 +0200
                Re: C: How to convert a \0 char into a dot for printf output? "Steven Levine" <steve53@nomail.earthlink.net> - 2018-05-21 09:42 -0500
                Re: C: How to convert a \0 char into a dot for printf output? Andreas Schnellbacher <aschn@despammed.com> - 2018-05-21 18:37 +0200
                Re: C: How to convert a \0 char into a dot for printf output? nospam_2018@efbe.prima.de - 2018-05-20 19:06 +0200
                Re: C: How to convert a \0 char into a dot for printf output? Andreas Schnellbacher <aschn@despammed.com> - 2018-05-20 23:30 +0200
                Re: C: How to convert a \0 char into a dot for printf output? Peter Flass <peter_flass@yahoo.com> - 2018-05-20 18:03 -0400
                Re: C: How to convert a \0 char into a dot for printf output? Lars Erdmann <lars.erdmann@arcor.de> - 2018-05-21 09:07 +0200
                Re: C: How to convert a \0 char into a dot for printf output? Andreas Schnellbacher <aschn@despammed.com> - 2018-05-21 11:30 +0200
                Re: C: How to convert a \0 char into a dot for printf output? "Steven Levine" <steve53@nomail.earthlink.net> - 2018-05-21 10:01 -0500
                Re: C: How to convert a \0 char into a dot for printf output? Andreas Schnellbacher <aschn@despammed.com> - 2018-05-21 18:41 +0200
                Re: C: How to convert a \0 char into a dot for printf output? nospam_2018@efbe.prima.de - 2018-05-21 22:56 +0200
                Re: C: How to convert a \0 char into a dot for printf output? "Steven Levine" <steve53@nomail.earthlink.net> - 2018-05-22 10:00 -0500
                Re: C: How to convert a \0 char into a dot for printf output? Andreas Schnellbacher <aschn@despammed.com> - 2018-05-22 21:37 +0200
                Re: C: How to convert a \0 char into a dot for printf output? Andreas Schnellbacher <aschn@despammed.com> - 2018-05-22 21:41 +0200
                Re: C: How to convert a \0 char into a dot for printf output? Andreas Schnellbacher <aschn@despammed.com> - 2018-05-23 23:56 +0200
                Re: C: How to convert a \0 char into a dot for printf output? nospam_2018@efbe.prima.de - 2018-05-22 21:44 +0200
          Re: C: How to convert a \0 char into a dot for printf output? Peter Flass <peter_flass@yahoo.com> - 2018-05-19 11:42 -0400
            Re: C: How to convert a \0 char into a dot for printf output? Andreas Schnellbacher <aschn@despammed.com> - 2018-05-19 18:13 +0200
  Re: C: How to convert a \0 char into a dot for printf output? Andreas Kohl <ak120@arcor.de> - 2018-05-21 09:05 +0200
    Re: C: How to convert a \0 char into a dot for printf output? Andreas Schnellbacher <aschn@despammed.com> - 2018-05-21 11:35 +0200

csiph-web