• 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: Brian Howard <email@hidden>
  • Date: Tue, 5 Jun 2001 15:34:26 -0400

On Tuesday, June 5, 2001, at 03:05 PM, Samuel Hornus wrote:

> Hi Brian
>
> Le mardi 5 juin 2001, ` 06:36, Brian Howard a icrit :
>
>> 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[]".
>
> This has *NOTHING* to do with Apple or Cocoa.

Then why is it contained in a book called "Learning Cocoa" written by
Apple?

> This is the BASIC of C programming laguage. So my best advice would be
> you to get out and buy a
> C programming guide book.

Well, I have a 700 page book on C programming and the index shows
nothing about this. I also have a 600 page book on UNIX and it only
mentions argv as a shell variable with NO further information. I do
try, damnit!

> main is NOT a variable, main is the MAIN function of the program you
> are about to compile.
> main() is where your program will start.

I understand now, thanks to others, that main is a function that RETURNS
a variable. Pardon me but I said I was only guessing.

> I repeat myself : DO buy a book about programming in C language.

I must have picked the wrong programming book, "The Art and Science of
C" by Eric S. Roberts. Since he has a Ph.D. in computer science from
Harvard and is a professor at Stanford, I assumed he might know what he
was talking about. Silly me.
>
> --
> Samuel Hornus


  • Follow-Ups:
    • Re: int question
      • From: Vince DeMarco <email@hidden>
    • Re: int question
      • From: Jorge Salvador Caffarena <email@hidden>
    • Re: int question
      • From: Andreas Monitzer <email@hidden>
  • Prev by Date: Re: Threads in Apps
  • Next by Date: Re: [NSApp setDelegate]
  • Previous by thread: Re: int question
  • Next by thread: Re: int question
  • Index(es):
    • Date
    • Thread