Sunday, July 12, 2009

C programming?

can anyone give the explanation for the following


main()


int main()


void main()


main(void)


void main(void)


int main(void)

C programming?
main() by itself would be the same as any other function calling it to do what is inside of it.





int main() would be initializing it and would also require a return(x) with x being an integer (int). C recognizes 0 to end the program, so the last line in that function should be return(0);





void means that nothing needs to be returned, so you could just have "return();"





most programs need to have function main, it is the first to be run and usually controlls the rest of the program.





I hope that helps.
Reply:you better refer the book programming in Ansi C written by Balaguruswamy


this book helps u in clearing your all doubts in c programming
Reply:integers
Reply:main() is the beginning of the main program.





int main() same as above except that when the main program terminates it passes some integer value back to the OS. Depending on the implimentation, this can cause various messages, etc.





void main() same as main() except the word 'void' explicitly indicates that main passes nothing back to the OS





main(void) explicitly indicates that nothing is passed to 'main' by the OS





void main(void) explicitly says that main is not passed anything from the OS at invocation and does not pass anything back to the OS at termination





int main(void) explicitly indicates that the program main is not passed anything at invocation and at termination it passes an integer value back to the OS.





All of these are implimentation dependent. Various compilers use them as part of their 'standard' C syntax





If you think that the phrase "ANSII Standard C" is anything but a marketing slogan, you haven't been a programmer for very long ☺








Doug
Reply:I don't understand the question, and I am pretty damn good at C.





Are you trying to say that this is the text of a program?
Reply:whatever u write before a function is called its prototype


int main() means at the completion of the function it would return a int value that is the function's purpose is to find an integer value





whatever is written btwen brakets is the variable the function is accepting


main(void) is equivalent to main() as both mean they take no parameters





at last int main(void) means that the function would return or find the integer answer and is taking no parameter from any other function-void


still confuse, read ur book
Reply:#define ZERO 0


#include %26lt;stdio.h%26gt;





main() {


/*---


main() is usually the 1st function to be executed when you run a C code.





'void' and 'int' are data types. if you write 'int main()', this means that the main function will return an integer to the operating system (or shell). 'void main()' means you're not returning anything in special -- the C compiler-linker couple will assume standard prespecified values as the returning figure (potentially ZERO).





the 'void' in 'int main(void)' emphasizes that you're not expecting any special argument passed from the opsys (or shell). the same for 'void main(void)'.


---*/


printf("Hello, world.");


}

alstroemeria

No comments:

Post a Comment