Thread: int main parameters

  1. #1
    Registered User
    Join Date
    Dec 2006
    Location
    Jacksonville, AR
    Posts
    91

    Question int main parameters

    Hello,

    Code:
    int main(int argc, char **argv)
    Does this mean int main takes two parameters argc and double(?)pointer argv? What does double pointer mean? Does that pertain to an array?
    Is this used when your program uses a function from the compiler package?

    Thanks!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Read the tutorial on accepting command line arguments.

    Quote Originally Posted by alyeska
    What does double pointer mean?
    Pointer to a pointer. The tutorial uses slightly different syntax but it means the same thing.
    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

  3. #3
    a newbie :p
    Join Date
    Aug 2008
    Location
    Zurich, Switzerland, Switzerland
    Posts
    91
    I guess it is not an ordinary ptr-to-ptr. It is special: a special issue for argument.
    Check here:
    http://www.codeproject.com/KB/cpp/PtrToPtr.aspx
    Last edited by auralius; 01-13-2009 at 04:58 AM.

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    No, it's not special. It's an ordinary pointer to pointer. You just interpret both pointees as arrays. But that's not particularly special.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    a newbie :p
    Join Date
    Aug 2008
    Location
    Zurich, Switzerland, Switzerland
    Posts
    91
    yup, you're right...
    my mistake...


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 11-30-2007, 03:51 AM
  2. Need help understanding info in a header file
    By hicpics in forum C Programming
    Replies: 8
    Last Post: 12-02-2005, 12:36 PM
  3. Replies: 4
    Last Post: 11-23-2003, 07:15 AM
  4. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2003, 12:26 AM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 05:26 PM