Thread: What does **++argv mean

  1. #1
    Registered User
    Join Date
    Jun 2016
    Posts
    1

    What does **++argv mean

    Code:
    #include<stdio.h>
    int main(int argc , char *argv[])
               {
                   printf("%c\n",**++argv);
               }
    ./a.out 5 gives the output 5
    Code:
    #include<stdio.h>
    int main(int argc , char *argv[])
               {
                   printf("%c\n",*argv[1]);
               }
    ./a.out 5 gives the output 5

    is **++argv sameas *argv[1]?
    can any one explain

  2. #2
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    is **++argv sameas *argv[1]
    Yes.
    In general,
    a[x] is same as *(a + x)

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Actually, no, they are not equivalent. Recall that ++argv modifies argv, but argv[1] does not.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Apr 2013
    Posts
    1,658
    If these work, then **++argv is the same as *(++argv)[0] or (++argv)[0][0].

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. if argv
    By Muscovy in forum C++ Programming
    Replies: 2
    Last Post: 07-15-2009, 11:08 PM
  2. main() ; argv[1] = string at argv[0]???
    By UCnLA in forum C Programming
    Replies: 1
    Last Post: 03-31-2008, 12:16 AM
  3. Question on *argv vs. *argv[]
    By movl0x1 in forum C Programming
    Replies: 3
    Last Post: 05-29-2007, 06:03 PM
  4. argv
    By Sebastiani in forum C Programming
    Replies: 1
    Last Post: 03-04-2002, 06:41 PM
  5. argv
    By GaPe in forum C Programming
    Replies: 7
    Last Post: 01-07-2002, 04:25 PM

Tags for this Thread