php hit counter

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is difference among main() int main() void main()
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support
#2
In C and C++, int main() is proper code, because main() always returns int according to the latest specifications for C and C++.

int main() with no arguments is interpreted as int main(void). Earlier versions of the spec and pre-standard versions of C required explicit declaration [ie. int main(void)] but the current specs for both languages allow for implicit declaration. I believe even main() would be acceptable, though not formal enough for some people.

void main (void) is not proper code, because main() always returns int. That's just how it's defined by the specification. Most compilers will accept it with just a warning, and interpret it as int main(void) before compiling. It's not likely to cause any problems as you can be fairly (but not 100%) confident that the compiler will fix it for you. You will find some books that use void main(void), but it's considered incorrect, or at least sloppy.

main(int argc, char *argv[])

argc is the number of argv. In one sense.
argc is the number of arguments like -b,-ab . In other sense.

argv is the argument . like -b , -ab ..., but first argv[0]=filename with full path

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Messages In This Thread
What is difference among main() int main() void main() - by Vuhelper - 05-02-2011, 05:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  What is the difference among calloc function ,malloc function and recalloc function? Vuhelper 0 34,665 05-31-2012, 01:46 AM
Last Post: Vuhelper
  what is main logic behind turning a register into byte count other than multiplying 2 Vuhelper 0 2,873 05-31-2012, 01:29 AM
Last Post: Vuhelper
  What is difference among Binary Tree, Complete Binary Tree and Binary Search Tree? Vuhelper 2 4,437 03-18-2012, 12:47 AM
Last Post: Xpert
  Explain the difference b/w Null Pointer and Null Nodes? C++ 2012 Vuhelper 0 2,002 01-06-2012, 12:24 AM
Last Post: Vuhelper
  What is the difference b/w Inorder Traversal and Inorder Successor? 2012 Vuhelper 0 1,836 01-06-2012, 12:23 AM
Last Post: Vuhelper
  Argc(argument count) and argv(argument value) are used in main function Vuhelper 0 2,084 01-04-2012, 10:42 PM
Last Post: Vuhelper
  what is the difference between 1. Double Right-Left Rotation 2. Double Left-Right Rot Vuhelper 0 2,077 01-04-2012, 10:37 PM
Last Post: Vuhelper
  Why we write main rgc,char**argv in C++ 2012 Vuhelper 0 3,073 01-04-2012, 10:36 PM
Last Post: Vuhelper
  What is the difference between “object = this->object” and “this->object=object”? Vuhelper 0 4,099 01-04-2012, 10:17 PM
Last Post: Vuhelper
  What is difference between a complete binary tree and strictly binary tree? Vuhelper 0 4,543 11-05-2011, 05:24 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support