answersLogoWhite

0


Best Answer

int main() refers that main function returns an integer value, where the integer value represent the program execution status. This status value is sent to the Operating System. If you follow strictly follow the rules, then it should be int main not void main()

User Avatar

Wiki User

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

Wiki User

7y ago

All C programs must return an integer value to indicate success or failure to the operating environment, even if that environment does not actually use or require the value. Windows systems in particular do not make use of the return value, but batch files can inspect the "error level" returned by a program. Although the C standard does not enforce this aspect, the abort function must still return a value. Thus void main, while not invalid, is considered bad programming practice. Note that void main is not permitted in C++. The correct form is int main.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

All functions must return something. void is used to indicate that the function's return value is void; so no memory is allocated to the function's return value.

void main() is not a valid function signature. The main() function is the entry point of the application and it must return an integer: int main(). A non-zero return value is usually used to denote an error condition, while zero indicates success. The program that called your program (such as a script or another executable) can use the return value to determine if the call was successful or not.

A program with a void main() function is not a valid program and many compilers will not accept it. Those that do will alter the signature during compilation and return 0, whether the program ran successfully or not. Example code that contains void main() is usually only done for brevity (or laziness), but generally will not compile.

Void pointers, *void, are used to indicate a pointer variable of unknown type. A pointer variable is allocated (4 bytes on a 32-bit system), but the programmer must determine the type of pointer before attempting to access the pointer via indirection.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

'void' is the return type of the 'main'. At least in some langauges; in C/C++ it is 'int'.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between int main and int void?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the difference between declaration and a definition in C with small example?

declaration examples:int main (void);extern int somevariable;definition examples:int main (void) { puts ("Hello world"); return 0; }int somevariable;


How is main function declared?

int main (void) or int main(int a, char **p)


What is earlier declaration for main?

pick one: int main (void); int main (int argc, char **argv); int main (int argc, char **argv, char **envp);


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)


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.


In c How do you access variable declared in main in other function?

Only if you pass a pointer to it, eg: void sub (int *into) { *into= 3; } int main (void) { int myvariable; sub (&myvariable); return 0; }


How do you Send arrays to function?

Simply by sending the base address from main() and catching that in a pointer in the pointer. void main() { int a[20]; sort(a); } void fun(int *p) { }


Types of main function in C programming?

minimalist: int main (void); standard: int main (int argc, char **argv); unix-only: int main (int argc, char **argv, char **envp);


Why do you write void to the first of main in c?

This is really unclear. If you're asking why you should write void main() then the answer is that you shouldn't. main can return an int as an error code, so it's better to do int main() instead.


Where does the main function starts and end in c program?

The entry point of a C program is the main function.The function signature might be like one of these:1. int main (void)2. int main (int argc, char *argv[])


What is memory corruption in C?

Memory corruption in C refers to situations where a program unintentionally alters the contents of memory locations that it is not supposed to access or modify. This can lead to unexpected and potentially dangerous behavior, such as crashes, data corruption, or security vulnerabilities. Memory corruption in C is often a result of issues like buffer overflows, uninitialized variables, or improperly managed memory allocations.


What is the function of void main in c language?

Actually, it is:int main (void)orint main (int, char **)the point where the execution of the program begins