pass by address

Discussion in 'C Programming' started by Bill Cunningham, May 2, 2014.

  1. Bill Cunningham

    Ken Brody Guest

    On 5/5/2014 3:23 PM, Bill Cunningham wrote:
    I'm coming in late to this discussion, but compilers are allowed to accept
    invalid code, and (with some exceptions) are allowed to compile such code
    without a peep.

    A compiler is allowed to accept:

    int i;
    printf("%d %d %d\n",i++,i++,i++);

    and even generate the output that you expected. That doesn't mean the code
    was valid.
    Ken Brody, May 6, 2014
    1. Advertisements

  2. Bill Cunningham

    Ken Brody Guest

    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);
    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?"
    Ken Brody, May 6, 2014
    1. Advertisements

  3. [snip]
    They say there's a difference in coders and programmers.
    Bill Cunningham, May 6, 2014
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.