Awesome program with pointers.

This is a discussion on Awesome program with pointers. within the General Discussions forums, part of the Community Boards category; Just saw this and thought other people might enjoy it. If you can't tell from the code, I strongly recommend ...

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    32

    Awesome program with pointers.

    Just saw this and thought other people might enjoy it. If you can't tell from the code, I strongly recommend compiling/running.

    Code:
    #include<stdio.h>
    
    
    char *c[] = { "ENTER", "NEW", "POINT", "FIRST" };
    char **cp[] = { c+3, c+2, c+1, c };
    char ***cpp = cp;
    
    
    main()
    {
        printf("%s", **++cpp);
        printf("%s ", *--*++cpp+3);
        printf("%s", *cpp[-2]+3);
        printf("%s\n", cpp[-1][-1]+1);
        return 0;
    }
    EDIT: I did NOT write this.
    Last edited by Mark Labarbara; 01-02-2012 at 09:19 PM.

  2. #2
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,657
    Pointers can be fun but the author forgot to make it well defined.
    *--*++cpp+3
    At least I'm pretty sure, 'cause expressions like this require the variable to be modified twice.

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    32
    Quote Originally Posted by whiteflags View Post
    Pointers can be fun but the author forgot to make it well defined.
    *--*++cpp+3
    At least I'm pretty sure, 'cause expressions like this require the variable to be modified twice.
    I have no idea, I am pretty new to programming.

    Either way, when you compile and run it, the output is pretty sweet

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,589
    Quote Originally Posted by whiteflags
    Pointers can be fun but the author forgot to make it well defined.
    *--*++cpp+3
    At least I'm pretty sure, 'cause expressions like this require the variable to be modified twice.
    It looks well defined because the dereferencing causes different objects to be modified.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5

    Join Date
    May 2005
    Posts
    1,041
    Gave me a chuckle.
    I'm not immature, I'm refined in the opposite direction.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Awesome C++ College Textbook
    By HarleyJohn in forum C++ Programming
    Replies: 4
    Last Post: 04-29-2009, 11:35 AM
  2. Awesome?
    By pianorain in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 02-01-2005, 04:08 PM
  3. this is awesome
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 02-27-2004, 02:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21