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


Groups > comp.lang.c > #19883

Re: The question regarding type of pointers

From Kaz Kylheku <kaz@kylheku.com>
Newsgroups comp.lang.c
Subject Re: The question regarding type of pointers
Date 2012-04-25 04:51 +0000
Organization Aioe.org NNTP Server
Message-ID <20120424213222.491@kylheku.com> (permalink)
References <a5d5b150-de6c-4bdf-bc53-5dd21eddc81c@a8g2000pbe.googlegroups.com>

Show all headers | View raw


On 2012-04-25, somenath <somenathpal@gmail.com> wrote:
> Hello All,
>
> I am very confused about the output of the following program.
>
> #include<stdio.h>
> int  daytab[2][13] = {
> 							{0,31,28,31,30,31,30,31,31,30,31,30,31},
> 							{0,31,29,31,30,31,30,31,31,30,31,30,31},

[ ... ]

> My question is how  the below line getting evaluated and resulting
> correct output?
> day += *(*(daytab+leap)+i);

This was written by an incompetent who had no regard for writing
clear, maintainable code.

The proper style for this expression, given how daytab operates as a
straightforward two-dimensional table, and how leap and i are straighforward
integer indices into the dimensions of that table, is this:

  day += daytab[leap][i];

There is absolutely no need to obfuscate this perfectly good expression
by replacing E[I] with *((E) + I) even once, let alone twice.

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


Thread

The question regarding type of pointers somenath <somenathpal@gmail.com> - 2012-04-24 21:05 -0700
  Re: The question regarding type of pointers Kaz Kylheku <kaz@kylheku.com> - 2012-04-25 04:51 +0000
  Re: The question regarding type of pointers "Heinrich Wolf" <invalid@invalid.invalid> - 2012-04-25 07:15 +0200
    Re: The question regarding type of pointers Philip Lantz <prl@canterey.us> - 2012-04-25 00:46 -0700
      Re: The question regarding type of pointers "Heinrich Wolf" <invalid@invalid.invalid> - 2012-04-25 09:52 +0200
  Re: The question regarding type of pointers Philip Lantz <prl@canterey.us> - 2012-04-25 01:09 -0700
  Re: The question regarding type of pointers Barry Schwarz <schwarzb@dqel.com> - 2012-04-25 11:22 -0700
    Re: The question regarding type of pointers somenath <somenathpal@gmail.com> - 2012-04-27 23:05 -0700
      Re: The question regarding type of pointers pete <pfiland@mindspring.com> - 2012-04-28 14:59 -0400
        Re: The question regarding type of pointers somenath <somenathpal@gmail.com> - 2012-04-28 20:27 -0700
          Re: The question regarding type of pointers James Kuyper <jameskuyper@verizon.net> - 2012-04-29 07:37 -0400
            Re: The question regarding type of pointers pete <pfiland@mindspring.com> - 2012-04-29 09:34 -0400
              Re: The question regarding type of pointers James Kuyper <jameskuyper@verizon.net> - 2012-04-29 11:54 -0400
          Re: The question regarding type of pointers pete <pfiland@mindspring.com> - 2012-04-29 09:24 -0400
            Re: The question regarding type of pointers somenath <somenathpal@gmail.com> - 2012-04-29 07:38 -0700
              Re: The question regarding type of pointers James Kuyper <jameskuyper@verizon.net> - 2012-04-29 12:01 -0400
                Re: The question regarding type of pointers somenath <somenathpal@gmail.com> - 2012-04-29 09:29 -0700
    Re: The question regarding type of pointers somenath <somenathpal@gmail.com> - 2012-04-27 22:22 -0700
      Re: The question regarding type of pointers Barry Schwarz <schwarzb@dqel.com> - 2012-04-28 20:14 -0700
        Re: The question regarding type of pointers somenath <somenathpal@gmail.com> - 2012-04-28 22:17 -0700
          Re: The question regarding type of pointers James Kuyper <jameskuyper@verizon.net> - 2012-04-29 07:32 -0400

csiph-web