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


Groups > comp.lang.c > #44060

Re: pass by address

From Ken Brody <kenbrody@spamcop.net>
Newsgroups comp.lang.c
Subject Re: pass by address
Date 2014-05-06 11:16 -0400
Organization A noiseless patient Spider
Message-ID <lkauc8$dl5$1@dont-email.me> (permalink)
References (3 earlier) <lk4efb$vj2$1@dont-email.me><1phbm9t64tdkhq9pq5ng42v15s44tr01e0@4ax.com><slrnlmbvg5.m4n.tth@hangartistique.cispeo.fr> <lnr44aj596.fsf@nuthaus.mib.org> <lk632v$uk1$1@dont-email.me> <6c190c02-b61f-4419-ace6-b0dbadd65ed9@googlegroups.com> <lk9k1m$fiv$1@dont-email.me>

Show all headers | View raw


On 5/5/2014 11:13 PM, Bill Cunningham wrote:
> "Malcolm McLean" <malcolm.mclean5@btinternet.com>
>
> Why do you need to print out a pointer?
>> I'm sure someone can think of a reason, but normally, only for debugging.
>> If a program is behaving strangely, you might want to print out a few
>> pointer values to see what they look like.
>> So typically you'll insert a daignostic printf("%p\n", ptr), take a
>> look at the problem, fix it, then delete the code.
>
>      In real life I can't think of why. But my tutorials that are no good
> give me those examples. There  are certain things that you don't pick up out
> of the tutorials I now have that you can't get except from those with
> experience.

I can think of tutorials having a good reason to want to display pointers. 
Consider explaining why "str1==str2" is not the same as "strcmp(str1,str2)".

=====
#define	MyString "Hello, world.\n"
char foo1[] = MyString;
char bar1[] = MyString;
char *foo2 =  MyString;
char *bar2 =  MyString;
...
printf("foo1 is at address %p\nbar1 is at address %p\n",foo1,bar1);
printf("foo2 points to %p\nbar2 points to %p\n",foo2,bar2);
....
=====

> The thing is I'm getting a little leary of the advice I'm
> getting. It's like asking someone for directions and they point to the right
> with the right arm and the left with the left arm and they don't seem to
> understand what I just asked.

Perhaps it's because you ask for directions with questions like "I'm trying 
to drive backwards down a one-way street, but I'm not sure which key fits 
the ignition -- can you tell me how to put gas in the tank?"

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


Thread

pass by address "Bill Cunningham" <nosapm@nspam.invalid> - 2014-05-02 16:53 -0400
  Re: pass by address "Bill Cunningham" <nosapm@nspam.invalid> - 2014-05-02 17:03 -0400
    Re: pass by address "Bill Cunningham" <nosapm@nspam.invalid> - 2014-05-02 17:20 -0400
  Re: pass by address Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-05-02 17:58 -0400
    Re: pass by address "Bill Cunningham" <nosapm@nspam.invalid> - 2014-05-02 18:09 -0400
      Re: pass by address Barry Schwarz <schwarzb@dqel.com> - 2014-05-02 16:37 -0700
        Re: pass by address gazelle@shell.xmission.com (Kenny McCormack) - 2014-05-02 23:43 +0000
          Re: pass by address Richard <rgrdev_@gmail.com> - 2014-05-03 15:58 +0200
            Re: pass by address gazelle@shell.xmission.com (Kenny McCormack) - 2014-05-03 14:08 +0000
              Re: pass by address Barry Schwarz <schwarzb@dqel.com> - 2014-05-03 10:38 -0700
                Re: pass by address Richard <rgrdev_@gmail.com> - 2014-05-03 21:13 +0200
        Re: pass by address "Bill Cunningham" <nosapm@nspam.invalid> - 2014-05-03 01:46 -0400
        Re: pass by address "Bill Cunningaham" <nospam@nspam.invalid> - 2014-05-03 11:22 -0400
          Re: pass by address James Kuyper <jameskuyper@verizon.net> - 2014-05-03 12:13 -0400
          Re: pass by address Keith Thompson <kst-u@mib.org> - 2014-05-03 12:34 -0700
            Re: pass by address Richard <rgrdev_@gmail.com> - 2014-05-03 22:33 +0200
            Re: pass by address glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-05-03 21:21 +0000
              Re: pass by address "Bill Cunningham" <nospam@nspam.invalid> - 2014-05-04 00:08 -0400
                Re: pass by address Barry Schwarz <schwarzb@dqel.com> - 2014-05-03 21:52 -0700
                Re: pass by address Tonton Th <tth@nowhere.invalid> - 2014-05-04 08:44 +0000
                Re: pass by address Keith Thompson <kst-u@mib.org> - 2014-05-04 01:51 -0700
                Re: pass by address "Bill Cunningham" <nospam@nspam.invalid> - 2014-05-04 15:06 -0400
                Re: pass by address Barry Schwarz <schwarzb@dqel.com> - 2014-05-04 15:35 -0700
                Re: pass by address Richard <rgrdev_@gmail.com> - 2014-05-05 12:01 +0200
                Re: pass by address Barry Schwarz <schwarzb@dqel.com> - 2014-05-05 11:46 -0700
                Re: pass by address "Bill Cunningham" <nospam@nspam.invalid> - 2014-05-05 14:18 -0400
                Re: pass by address Barry Schwarz <schwarzb@dqel.com> - 2014-05-05 11:55 -0700
                Re: pass by address "Bill Cunningham" <nospam@nspam.invalid> - 2014-05-05 15:20 -0400
                Re: pass by address "Bill Cunningham" <nospam@nspam.invalid> - 2014-05-05 15:23 -0400
                Re: pass by address Ken Brody <kenbrody@spamcop.net> - 2014-05-06 11:02 -0400
                Re: pass by address "Bill Cunningham" <nospam@nspam.invalid> - 2014-05-06 14:46 -0400
                Re: pass by address Richard <rgrdev_@gmail.com> - 2014-05-05 12:00 +0200
                Re: pass by address Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-05-05 14:50 -0700
                Re: pass by address "Bill Cunningham" <nospam@nspam.invalid> - 2014-05-05 23:13 -0400
                Re: pass by address "Osmium" <r124c4u102@comcast.net> - 2014-05-05 23:09 -0500
                Re: pass by address "Bill Cunningham" <nospam@nspam.invalid> - 2014-05-06 08:55 -0400
                Re: pass by address Ken Brody <kenbrody@spamcop.net> - 2014-05-06 11:16 -0400
                Re: pass by address Richard <rgrdev_@gmail.com> - 2014-05-06 18:13 +0200
                Re: pass by address Kaz Kylheku <kaz@kylheku.com> - 2014-05-04 21:06 +0000
                Re: pass by address Kaz Kylheku <kaz@kylheku.com> - 2014-05-04 23:50 +0000
                Re: pass by address Keith Thompson <kst-u@mib.org> - 2014-05-04 12:36 -0700
                Re: pass by address "Bill Cunningham" <nospam@nspam.invalid> - 2014-05-05 14:21 -0400
                Re: pass by address Keith Thompson <kst-u@mib.org> - 2014-05-04 01:29 -0700
                Re: pass by address "Bill Cunningham" <nospam@nspam.invalid> - 2014-05-04 15:09 -0400
        Re: pass by address "Bill Cunningaham" <nospam@nspam.invalid> - 2014-05-03 11:32 -0400
  Re: pass by address Barry Schwarz <schwarzb@dqel.com> - 2014-05-02 16:43 -0700
    Re: pass by address "Bill Cunningham" <nosapm@nspam.invalid> - 2014-05-03 01:54 -0400
      Re: pass by address Richard <rgrdev_@gmail.com> - 2014-05-03 15:59 +0200
    Re: pass by address "Bill Cunningham" <nosapm@nspam.invalid> - 2014-05-03 02:08 -0400
      Re: pass by address "Bill Cunningaham" <nospam@nspam.invalid> - 2014-05-03 11:46 -0400
    Re: pass by address Kaz Kylheku <kaz@kylheku.com> - 2014-05-03 21:43 +0000

csiph-web