| | |
void before main ()
![]() |
0
#2 Oct 19th, 2009
•
•
•
•
I am a beginner in c and would like someone tp help me . My question is why I have to write void before main to execute the c program.
#include<stdio.h>
void main()
clrscr();
{
printf("Hello")
}
This is a very simple program. But I am unable to execute it if I don't write void before main().
C Syntax (Toggle Plain Text)
int main() { printf("Hello"); return 0; }
Last edited by gerard4143; Oct 19th, 2009 at 1:09 am.
1
#6 Oct 19th, 2009
•
•
•
•
Is it true that some compilers require void before main ?
C Syntax (Toggle Plain Text)
int main() { /*...*/ }
C Syntax (Toggle Plain Text)
int main(int argc, char* argv[]) { /*...*/ }
•
•
•
•
Why this error ?
-Tommy (For Great Justice!) Gunn
•
•
Join Date: Oct 2009
Posts: 1
Reputation:
Solved Threads: 0
-2
#7 Oct 19th, 2009
[QUOTE=seo2005;1019063]I am a beginner in c and would like someone tp help me . My question is why I have to write void before main to execute the c program.
#include<stdio.h>
void main()
clrscr();
{
printf("Hello")
}
of course it is a simple program but the void is responsible to return the value.if u dont put void before main() then how should ur program return the desire value.......
but you can also run the program without puting void......
try it.........
#include<stdio.h>
main()
{
clrscr();
printf("hello");
return 0()
}
here return 0() work as void and it returns the vlue of program..
note:-
1) put ; after the end of printf("hello");
===============================================
i hope my answer satisfies you.......
#include<stdio.h>
void main()
clrscr();
{
printf("Hello")
}
of course it is a simple program but the void is responsible to return the value.if u dont put void before main() then how should ur program return the desire value.......
but you can also run the program without puting void......
try it.........
#include<stdio.h>
main()
{
clrscr();
printf("hello");
return 0()
}
here return 0() work as void and it returns the vlue of program..
note:-
1) put ; after the end of printf("hello");
===============================================
i hope my answer satisfies you.......
0
#8 Oct 20th, 2009
except for Tom's...
Why you don't use
void with main() : click here The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
![]() |
Similar Threads
- Why NOT void main() (C++)
- int main() or void main() ??!! (C++)
Other Threads in the C Forum
- Previous Thread: Scheduling CPu algorithms
- Next Thread: Array of Pointers to structures...
| Thread Tools | Search this Thread |
#include * ansi array arrays asterisks binarysearch calculate centimeter changingto char character convert copyanyfile copyimagefile copypdffile creafecopyofanytypeoffileinc createprocess() database dynamic execv fflush fgets file floatingpointvalidation fork forloop function getlogicaldrivestrin givemetehcodez grade gtkwinlinux histogram homework i/o inches include infiniteloop input interest intmain() iso keyboard kilometer km license linked linkedlist linux looping lowest matrix meter microsoft mysql number oddnumber open opendocumentformat openwebfoundation owf pdf pointer posix power probleminc process program programming pyramidusingturboccodes radix read recursion recv recvblocked research reversing scheduling segmentationfault send sequential single socket socketprogramming stack standard strchr string suggestions systemcall test threads turboc unix urboc user variable whythiscodecausesegmentationfault win32api windowsapi






