| | |
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 * adobe ansi api array asterisks binarysearch centimeter changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc csyntax database directory dynamic execv feet fgets file fork function getlasterror getlogicaldrivestrin givemetehcodez global grade gtkgcurlcompiling gtkwinlinux hacking hardware highest histogram ide include incrementoperators infiniteloop input interest kernel keyboard kilometer license linked linkedlist linux linuxsegmentationfault list locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft motherboard mqqueue number odf opendocumentformat opensource owf pattern pdf performance pointer posix probleminc process program programming radix recursion recv repetition research reversing segmentationfault sequential single socket socketprograming standard string systemcall threads turboc unix user voidmain() wab whythiscodecausesegmentationfault windows.h windowsapi






