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


Groups > comp.lang.c > #95735

Re: A postfix pointer deference

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: A postfix pointer deference
Date 2016-11-04 10:36 +0000
Organization A noiseless patient Spider
Message-ID <877f8jilb2.fsf@bsb.me.uk> (permalink)
References <75137756-7d3c-440a-9749-c8ffdb228193@googlegroups.com>

Show all headers | View raw


luser droog <luser.droog@gmail.com> writes:

> #define REF [0]
>
> char *s = "hello";
> for(int i=0,n=strlen(s); i<n; i++)
>     putchar(s++ REF);

Why?  The usual idiom is *s++ and the whole loop would, most likely, not
be written using a counter:

  while (*s) putchar(*s++);

(I'm sure the putchar is just an example otherwise I'd suggest
fputs(s, stdout);)

Also, I'm not sure how the macro is helping.  Is the whole thing
intended to be a bit mysterious?

-- 
Ben.

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


Thread

A postfix pointer deference luser droog <luser.droog@gmail.com> - 2016-11-03 22:43 -0700
  Re: A postfix pointer deference fir <profesor.fir@gmail.com> - 2016-11-04 02:09 -0700
    Re: A postfix pointer deference fir <profesor.fir@gmail.com> - 2016-11-04 02:22 -0700
  Re: A postfix pointer deference Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-11-04 10:36 +0000
    Re: A postfix pointer deference luser droog <luser.droog@gmail.com> - 2016-11-04 08:53 -0700
      Re: A postfix pointer deference Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-11-04 16:44 +0000

csiph-web