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


Groups > comp.lang.c > #123554

Re: Updating pointer with result of sprintf

From "Pascal J. Bourguignon" <pjb@informatimago.com>
Newsgroups comp.lang.c
Subject Re: Updating pointer with result of sprintf
Date 2017-11-28 12:47 +0100
Organization Informatimago
Message-ID <m2zi76bp5u.fsf@informatimago.com> (permalink)
References <ovjd76$sbt$1@dont-email.me>

Show all headers | View raw


Noob <root@127.0.0.1> writes:

> Hello,
>
> Consider the following code:
>
>   unsigned char src[32]; /* initialized somewhere */
>   char buf[65];
>
>   for (i = 0; i < sizeof src; ++i)
>     buf += sprintf(buf, "%02x", src[i]);

In addition to the other answers, it's also missing:

    buf[64]=0;
    

-- 
__Pascal J. Bourguignon
http://www.informatimago.com

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Updating pointer with result of sprintf Noob <root@127.0.0.1> - 2017-11-28 11:19 +0100
  Re: Updating pointer with result of sprintf bartc <bc@freeuk.com> - 2017-11-28 11:02 +0000
  Re: Updating pointer with result of sprintf jacobnavia <jacob@jacob.remcomp.fr> - 2017-11-28 12:09 +0100
    Re: Updating pointer with result of sprintf Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-11-28 11:23 +0000
    Re: Updating pointer with result of sprintf Keith Thompson <kst-u@mib.org> - 2017-11-28 08:58 -0800
  Re: Updating pointer with result of sprintf Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-11-28 11:10 +0000
    Re: Updating pointer with result of sprintf Spiros Bousbouras <spibou@gmail.com> - 2017-11-28 16:51 +0000
      Re: Updating pointer with result of sprintf Keith Thompson <kst-u@mib.org> - 2017-11-28 09:24 -0800
      Re: Updating pointer with result of sprintf Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-11-29 00:33 +0000
        Re: Updating pointer with result of sprintf Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-11-29 00:36 +0000
        Re: Updating pointer with result of sprintf Spiros Bousbouras <spibou@gmail.com> - 2017-11-29 19:04 +0000
  Re: Updating pointer with result of sprintf "Pascal J. Bourguignon" <pjb@informatimago.com> - 2017-11-28 12:47 +0100
    Re: Updating pointer with result of sprintf "Pascal J. Bourguignon" <pjb@informatimago.com> - 2017-11-28 12:49 +0100
  Re: Updating pointer with result of sprintf scott@slp53.sl.home (Scott Lurndal) - 2017-11-28 14:19 +0000
    Re: Updating pointer with result of sprintf gazelle@shell.xmission.com (Kenny McCormack) - 2017-11-28 14:27 +0000
    Re: Updating pointer with result of sprintf Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-11-28 14:35 +0000
  Re: Updating pointer with result of sprintf "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-11-28 06:31 -0800
    Re: Updating pointer with result of sprintf "Pascal J. Bourguignon" <pjb@informatimago.com> - 2017-11-28 15:51 +0100
      Re: Updating pointer with result of sprintf "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-11-28 07:23 -0800
        Re: Updating pointer with result of sprintf "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-11-28 08:16 -0800
          Re: Updating pointer with result of sprintf Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-11-28 16:32 +0000
            Re: Updating pointer with result of sprintf "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-11-28 08:57 -0800
            Re: Updating pointer with result of sprintf "Pascal J. Bourguignon" <pjb@informatimago.com> - 2017-11-29 00:47 +0100
          Re: Updating pointer with result of sprintf "Pascal J. Bourguignon" <pjb@informatimago.com> - 2017-11-29 00:45 +0100
      Re: Updating pointer with result of sprintf Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-11-28 16:22 +0000
        Re: Updating pointer with result of sprintf Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-11-28 16:25 +0000
        Re: Updating pointer with result of sprintf "Pascal J. Bourguignon" <pjb@informatimago.com> - 2017-11-29 00:48 +0100
  Re: Updating pointer with result of sprintf Noob <root@127.0.0.1> - 2017-11-29 10:07 +0100
    Re: Updating pointer with result of sprintf Barry Schwarz <schwarzb@dqel.com> - 2017-11-29 09:18 -0800

csiph-web