View Single Post
  #4 (permalink)  
Old August 1st, 2003, 05:44 PM
merediths merediths is offline
Authorized User
 
Join Date: Jul 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to merediths
Default


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

  Are ANSI / ISO C. They are equivlant expressions. Kerrigan reomments the later in his book ... I use the former believing it to more clearly denote the data type as a pointer to a pointer.

void main(void)
 ||
void main()

  Are premissable C++ entry points. That is why say, gcc may give you an error while Visual Studio will not. g++, or gcc with appropriate command line arguements will compile the C++ constructs.

 It is important to note that while

  void main()
    &&
  void main(void)

  are equivlant constructs in C++ they are not so in C. This is because C++ has stronger type checking and interperts the empty parenthasis as meaning (void) while C interperts them as meaning unspecified argument list.

 In C++ the argument does matter ... void main(char ch) would not be linked as the entry point by default. The C++ compiler would mangle the name into something else...

  int main(int argc, char **argv)
  void main(int argc, char **argv)
  int main()
  int main(void)
  void main(void)
  int main(void)

  are valid C++ constructs. Some operating systems specify more -- UNIX for example also has a main that takes a pointer to a list of environment variables after **argv, for example.

Regards,
Meredith Shaebanyan



Reply With Quote