• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: int question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: int question


  • Subject: Re: int question
  • From: Scott Anguish <email@hidden>
  • Date: Tue, 5 Jun 2001 20:18:11 -0400

On Tuesday, June 5, 2001, at 12:36 PM, Brian Howard wrote:

Would someone be kind enough to explain this line of code:

int main (int argc, const char * argv[])

I can find no reference to "argc" or "const" or "argv", and I do not understand the use of the () at all.

The best I can guess at is that the variable "main" is an integer that could be either "argc" or the product of "const" times "argv[]".

Damn, I hate having to ask these dumb ass questions. Thanks again, Apple.


This has nothing at all to do with Apple documentation issues. This is basic C stuff

main is a function that returns an integer value
argc is an integer that holds the count of the number of items in the argv array

finally, the argv[[] is an array of const char * that has as many elements as the argc says.

This is the prototypical unix main. the command line parameters are contained in the argv[]. Even if you're using Cocoa apps, this will be the standard main.

As others have said, this is basic C stuff. There are loads of C books out there, and many are crap.. assuming that it might be good book based on the fact that it's written by a PhD is just a bad idea. I wouldn't even attempt to say that 'x' is a good book on the topic. I'd go to Amazon or FatBrain and browse and read the user comments.


BTW: I know that we all started at the same place, and that questions have to be asked (and answered) in order to learn. However, the accusatory and snippy tone that is prevalent in your particular questions (which always contain commentary) is a bit tiring. This is not an issue of poor documentation on Apple's part.


  • Follow-Ups:
    • Re: int question
      • From: John Pannell <email@hidden>
References: 
 >int question (From: Brian Howard <email@hidden>)

  • Prev by Date: NSTableView as an Outlet
  • Next by Date: Re: My Newbie Learning Question
  • Previous by thread: int question
  • Next by thread: Re: int question
  • Index(es):
    • Date
    • Thread