answersLogoWhite

0


Best Answer

The main function of a C or C++ program is int main (int argc, char *argv[]);

This is the programmer's supplied entry point. It is called by the run-time library after it has completed its own initialization. It is called main, and there must be one and only one main function at global scope in the link with this signature.

It takes two arguments, one of type int, the other of type pointer to array of pointers to strings. Traditionally, they are called argc and argv, but you can call them anything you want.

Argc holds the number of arguments on the command line. The command line includes the program's name, so argc will never be less than 1. If you had one actual argument, then argc would be 2, etc.

Argv is an array of pointers to strings. Argv[0] points to the program name. If argc is greater than 1, then argv[1] points to the first actual argument; if argc is greater than 2, then argv[2] points to the second actual argument, etc. Depending on the implementation, argv[0] might be just the program name, it might be its fully qualified path name, or it might be what was typed on the command line.

These arguments are parsed from the command line by simple white space, although some operating systems and libraries "might" handle quoted strings for you. Each argument is terminated by a null ('\0') character. It is important that you do NOT attempt to change any of these arguments. Treat them as read only. For example, if you are going to call certain library functions such as strtok on them, you need to make a copy first and call strtok on the copy. It is also important that you not attempt to reference a particular argv value without first checking that the argc value indicates its presence, otherwise you might cause a bus exception.

When your program is done, it is expected to return from main with an int value. The defined value for successful execution is zero. Small positive numbers, typically up to 255, depending on the operating system and library, can be used to indicate different conditions and errors.

Some implementations provide a third argument, char *envp[], which is an array of pointers to environment variable strings, terminated by one null pointer. This construct, however, is not ANSI standard. It is a common extension in Microsoft and Unix platforms, but other means should be used to access the environment, as it is not portable.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

The main() function in C or C++ programming is the programmer's entry point. Upon initial load into memory of a program, the run-time library's initialization routine is executed. The last thing that initialization routine does is call the programmer's main() function. Upon exit from main(), the run-time wraps things up, and the program terminates.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

The entry/start point of a program. It has 4 different signatures:

static void main();

static void main(string[] args);

static int main ();

static int main(string[] args);

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

The main entry point when the program gets executed.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is static void main in c sharp?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Is it compulsory to write static with void main?

Every C# application is started on the startup class' static Main method. Yes, it must be static, but void is not the only returned type. The 4 signatures:static void Main();static void Main(string[] arguments);static int Main();static int Main(string[] arguments);Ideally, there should be one and only one Main method in your application.


Which method is called first of all other methods when any application executed in c sharp?

static method Main() of the start object/class.There are 4 different signatures of Main():static void Main();static int Man();static void Main(string[] args);static int Main(string[] args);The starting object/class can have only one of them. Other classes or objects may have Main() method as well. (But why would be the question, Main() is NOT a good OO method name anyway. Method name should be a verb or start with a verb)


How can you display Hindi word in output of java program?

Class hindi { public static void main() { char c; for(c=2309;c<2362;c++) { System.out.println(" "+c); } } }


How do you write a program in c plus plus in which static variables are declared?

#include <stdio.h> static int myvar1, myvar2; int main (void) { puts ("It was easy"); return 0; }


Write a Java program to generate a copy of itself?

public class S{public static void main(String[]a){String o="public class S{public static void main(String[]a){String o=%c%s%c;System.out.printf(o,34,o,34);}}";System.out.printf(o,34,o,34);}}


Why to write void main in c programing?

it is always not necessary to write "void main " in c programming.it depends on the source code we use if we have to return a value then void is not necessary because void returns the null.While coding in borland C++ we need to write void main but we dont need it in dav c++.In C (and C++) the standard allows int main (void) and int main (int argc, char **argv)


C program to find square of number using do while loop?

class Abc { public static void main(String[] args) { System.out.println("Hello World!"); } }


How do you create a function that can pass through parameters in C programming language?

example: static void fun (int x) { printf ("x=%d\n", x); } int main (void) { fun (12); return 0; }


What is the role of void in functions of c?

this is a void main()int, char, are execution the program and it is not return the void.


Why do you use static key word in java main method?

Static means that something is done at compile time instead of when the object is instantiated, so you would therefore call a static method (doSomething()) through the class name rather than the object name. class A{ public static void B(){ } public void C(){ } } Let's say A instance = new A(); To access B you would say A.B(), while to access C you would say instance.C();


How do you print a star triangle in c sharp?

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication3 { class Program { static void Main(string[] args) { for (int i = 1; i <= 10; i++) { for (int j = 1; j <= i; j++) { Console.Write("* "); } Console.Write("\n"); } Console.Read(); } } }


Where void main is called in c?

main() is the function from where the execution starts.